Skip to content

Commit 810ccfb

Browse files
committed
chore: incremental deployment
1 parent 4a5a409 commit 810ccfb

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

.github/workflows/cd.yml

Lines changed: 37 additions & 4 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/downaload-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 file 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
@@ -40,16 +59,30 @@ jobs:
4059
uses: actions/download-artifact@v4
4160
with:
4261
name: build-files
62+
id: ${{ needs.upload.outputs.artifact-id }}
4363
path: dist/
4464

4565
# see https://help.aliyun.com/zh/oss/developer-reference/ossutil-overview/
4666
- name: Setup ossutil
4767
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
68+
VERSION=2.0.6-beta.01091200
69+
FILE_NAME=ossutil-$VERSION-linux-amd64.zip
70+
curl -o $FILE_NAME \
71+
https://gosspublic.alicdn.com/ossutil/v2-beta/$VERSION/$FILE_NAME
72+
unzip -j $FILE_NAME
5173
chmod +x ossutil
5274
./ossutil version
5375
76+
- name: Download diff list
77+
uses: actions/download-artifact@v4
78+
with:
79+
name: diff-list
80+
path: diff-list
81+
5482
- name: Deploy
55-
run: ./ossutil sync --delete --force dist/ oss://sustech-application/
83+
run: |
84+
BUCKET="oss://sustech-application"
85+
grep '^\*' diff-list | sed 's/^\* //' \
86+
| xargs -I{} ./ossutil rm -f "$BUCKET/{}"
87+
grep '^>' diff-list | sed 's/^> //' \
88+
| xargs -I{} ./ossutil cp -f dist/{} "$BUCKET/{}"

0 commit comments

Comments
 (0)