-
-
Notifications
You must be signed in to change notification settings - Fork 18
207 lines (177 loc) · 5.33 KB
/
ci.yml
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
name: CI
on:
push:
branches:
- main
paths-ignore:
- "README.md"
pull_request:
paths-ignore:
- "README.md"
schedule:
- cron: "13 13 * * *"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env:
HUGO_CACHEDIR: /tmp/hugo_cache
jobs:
renovate:
runs-on: ubuntu-22.04
timeout-minutes: 1
permissions: {}
steps:
- uses: actions/checkout@v4
- uses: peaceiris/workflows/[email protected]
with:
node-version-file: ".nvmrc"
cache: "npm"
- run: npm ci
- run: npm run test:renovate
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@v4
- 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@v4
with:
fetch-depth: 0
- uses: peaceiris/workflows/[email protected]
with:
node-version: "${{ needs.envs.outputs.NODE_VERSION }}"
hugo-version: "${{ needs.envs.outputs.HUGO_VERSION }}"
extended: true
- run: make npm-ci
- 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/[email protected]
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/[email protected]
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: 20
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: peaceiris/workflows/[email protected]
with:
node-version-file: ".nvmrc"
cache: ""
- name: Install lighthouse
run: sudo npm i -g [email protected]
- name: Run lighthouse
run: |
lighthouse \
--chrome-flags="--headless" \
--output html --output-path ./report.html \
'https://hugothemeiris.peaceiris.com'
- 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/[email protected]
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-22.04
timeout-minutes: 3
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }}
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: peaceiris/workflows/[email protected]
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-22.04
timeout-minutes: 3
if: ${{ github.ref == 'refs/heads/main' }}
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: peaceiris/workflows/[email protected]
with:
node-version: "${{ needs.envs.outputs.NODE_VERSION }}"
hugo-version: "${{ needs.envs.outputs.HUGO_VERSION }}"
extended: true
- uses: peaceiris/workflows/[email protected]
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