Skip to content

Commit bfa11ba

Browse files
committed
feat: incremental deployment
1 parent 4a5a409 commit bfa11ba

File tree

1 file changed

+45
-5
lines changed

1 file changed

+45
-5
lines changed

.github/workflows/cd.yml

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,30 @@ jobs:
2121
- name: Build
2222
run: bun run build
2323

24+
- name: Download previous build files
25+
uses: actions/download-artifact@v4
26+
with:
27+
name: build-files
28+
path: dist/
29+
continue-on-error: true
30+
2431
- name: Upload build files
2532
uses: actions/upload-artifact@v4
2633
with:
2734
name: build-files
2835
path: .vitepress/dist/
36+
retention-days: 90
37+
overwrite: true
38+
39+
- name: Diff artifacts
40+
run: rsync -ainc --delete .vitepress/dist dist/ | tee diff-list
41+
42+
- name: Upload diff list
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: diff-list
46+
path: diff-list
47+
overwrite: true
2948

3049
deploy:
3150
needs: build
@@ -45,11 +64,32 @@ jobs:
4564
# see https://help.aliyun.com/zh/oss/developer-reference/ossutil-overview/
4665
- name: Setup ossutil
4766
run: |
48-
curl -o ossutil-2.0.6-beta.01091200-linux-amd64.zip \
49-
https://gosspublic.alicdn.com/ossutil/v2-beta/2.0.6-beta.01091200/ossutil-2.0.6-beta.01091200-linux-amd64.zip
50-
unzip -j ossutil-2.0.6-beta.01091200-linux-amd64.zip
67+
VERSION=2.0.6-beta.01091200
68+
FILE_NAME=ossutil-$VERSION-linux-amd64.zip
69+
curl -o $FILE_NAME \
70+
https://gosspublic.alicdn.com/ossutil/v2-beta/$VERSION/$FILE_NAME
71+
unzip -j $FILE_NAME
5172
chmod +x ossutil
5273
./ossutil version
5374
54-
- name: Deploy
55-
run: ./ossutil sync --delete --force dist/ oss://sustech-application/
75+
- name: Download diff list
76+
uses: actions/download-artifact@v4
77+
with:
78+
name: diff-list
79+
path: ./
80+
81+
- name: Deploy - delete files
82+
continue-on-error: true
83+
run: |
84+
BUCKET="oss://sustech-application"
85+
touch delete-list
86+
grep '^\*' diff-list | sed 's/^\*.* dist\///' | tee delete-list
87+
./ossutil rm -rf --files-from delete-list $BUCKET
88+
89+
- name: Deploy - update files
90+
continue-on-error: true
91+
run: |
92+
BUCKET="oss://sustech-application"
93+
touch update-list
94+
grep '^>' diff-list | sed 's/^>.* dist\///' | tee update-list
95+
./ossutil cp -rf --files-from update-list ./ $BUCKET

0 commit comments

Comments
 (0)