Skip to content

Commit 79da430

Browse files
committed
feat: split deploy workflow into build & deploy jobs with caching
1 parent c6a8ef6 commit 79da430

File tree

1 file changed

+36
-7
lines changed

1 file changed

+36
-7
lines changed

.github/workflows/deploy.yml

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,57 @@ on:
99
workflow_dispatch:
1010

1111
jobs:
12-
build-and-deploy:
13-
runs-on: ubuntu-24.04
12+
build:
13+
runs-on: ubuntu-latest
1414
permissions:
15-
contents: write
15+
contents: read
1616

1717
steps:
1818
- name: Checkout
19-
uses: actions/checkout@v3
19+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
2020

2121
- name: Setup Node.js
22-
uses: actions/setup-node@v3
22+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 #v4.4.0
23+
with:
24+
node-version: '22.x'
25+
26+
- name: Cache node modules
27+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 #v4.2.4
2328
with:
24-
node-version: '18'
29+
path: node_modules
30+
key: node_modules-${{hashFiles('package-lock.json')}}
31+
restore-keys: |
32+
node_modules-
2533
2634
- name: Install dependencies
2735
run: npm ci
2836

2937
- name: Build
3038
run: npm run build
39+
40+
- name: Upload build
41+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 #v4.6.2
42+
with:
43+
name: out
44+
path: ./out
45+
if-no-files-found: error
46+
retention-days: 1
47+
48+
deploy:
49+
needs: build
50+
runs-on: ubuntu-latest
51+
permissions:
52+
contents: write
53+
54+
steps:
55+
- name: Download build from previous job
56+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 #v4.3.0
57+
with:
58+
name: out
59+
path: ./out
3160

3261
- name: Deploy
33-
uses: peaceiris/actions-gh-pages@v4
62+
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e #v4
3463
with:
3564
github_token: ${{ secrets.GITHUB_TOKEN }}
3665
publish_dir: ./out

0 commit comments

Comments
 (0)