Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ci.yml « workflows « .github - github.com/peaceiris/hugo-theme-iris.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c20a5d6005dcce875a0773b10d5108a331cfe719 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: CI

on:
  push:
    branches:
      - main
    paths-ignore:
      - "README.md"
  pull_request:
    paths-ignore:
      - "README.md"
  schedule:
    - cron: "13 13 * * *"

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: false

env:
  HUGO_CACHEDIR: /tmp/hugo_cache

jobs:
  envs:
    runs-on: ubuntu-22.04
    timeout-minutes: 1
    permissions: {}
    outputs:
      HUGO_VERSION: ${{ steps.envs.outputs.HUGO_VERSION }}
      NODE_VERSION: ${{ steps.envs.outputs.NODE_VERSION }}
    steps:
      - uses: actions/checkout@v3

      - name: Set envs
        id: envs
        run: |
          echo "HUGO_VERSION=$(make get-hugo-version)" | tee -a "${GITHUB_OUTPUT}"
          echo "NODE_VERSION=$(cat .nvmrc)" | tee -a "${GITHUB_OUTPUT}"

  deploy:
    needs: envs
    runs-on: ubuntu-22.04
    timeout-minutes: 3
    permissions:
      contents: write
      deployments: write
      pull-requests: write
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - uses: peaceiris/workflows/setup-hugo@v0.17.2
        with:
          node-version: "${{ needs.envs.outputs.NODE_VERSION }}"
          hugo-version: "${{ needs.envs.outputs.HUGO_VERSION }}"
          extended: true

      - uses: denoland/setup-deno@v1
        with:
          deno-version: "v1.x"

      - run: make fetch-data
        env:
          GITHUB_TOKEN: ${{ secrets.GH_PAT }}

      - run: make build-staging

      - name: Deploy to Netlify
        uses: nwtgck/actions-netlify@v1.2.4
        with:
          publish-dir: "./exampleSite/public"
          production-branch: main
          github-token: ${{ secrets.GITHUB_TOKEN }}
          deploy-message: "Deploy from GitHub Actions"
          enable-pull-request-comment: true
          enable-commit-comment: false
          overwrites-pull-request-comment: true
        env:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
        timeout-minutes: 1

      - run: make build-prod

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3.9.0
        if: ${{ github.ref == 'refs/heads/main' }}
        with:
          #deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./exampleSite/public
          allow_empty_commit: true
          user_name: "github-actions[bot]"
          user_email: "github-actions[bot]@users.noreply.github.com"

  lighthouse:
    needs: deploy
    if: ${{ github.ref == 'refs/heads/main' }}
    runs-on: ubuntu-22.04
    timeout-minutes: 3
    permissions:
      contents: write
    steps:
      - uses: peaceiris/workflows/setup-node@v0.17.2

      - name: Install lighthouse
        run: sudo npm i -g lighthouse

      - name: Run lighthouse
        run: |
          lighthouse \
            --chrome-flags="--headless" \
            --output html --output-path ./report.html \
            'https://hugothemeiris.peaceiris.app'

      - name: Upload result
        uses: actions/upload-artifact@v3
        with:
          name: lighthouse-report
          path: report.html

      - name: Prepare assets
        run: |
          mkdir ./public
          cp ./report.html ./public/report.html

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3.9.0
        with:
          deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
          publish_dir: ./public
          keep_files: true
          user_name: "github-actions[bot]"
          user_email: "github-actions[bot]@users.noreply.github.com"

  docker:
    needs: envs
    runs-on: ubuntu-20.04
    timeout-minutes: 3
    if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }}
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@v3

      - uses: peaceiris/workflows/setup-hugo@v0.17.2
        with:
          node-version: "${{ needs.envs.outputs.NODE_VERSION }}"
          hugo-version: "${{ needs.envs.outputs.HUGO_VERSION }}"
          extended: true

      - name: prepare
        run: |
          sed -i 's/enableGitInfo: true/# enableGitInfo: true/' exampleSite/config/_default/config.yaml

      - run: make docker-build

  setup:
    needs: envs
    runs-on: ubuntu-20.04
    timeout-minutes: 3
    if: ${{ github.ref == 'refs/heads/main' }}
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@v3

      - uses: peaceiris/workflows/setup-hugo@v0.17.2
        with:
          node-version: "${{ needs.envs.outputs.NODE_VERSION }}"
          hugo-version: "${{ needs.envs.outputs.HUGO_VERSION }}"
          extended: true

      - uses: peaceiris/workflows/setup-git@v0.17.2
        with:
          flags: "--global"

      - name: Create a new Hugo project
        run: |
          mkdir ~/homepage
          cp scripts/setup.sh ~
          cd ~
          bash ./setup.sh "homepage" "peaceiris"
          cd homepage
          npm ci
          hugo