Skip to content

chore: incremental deployment #24

chore: incremental deployment

chore: incremental deployment #24

Workflow file for this run

name: CD
concurrency: production
on:
push:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
run: bun install
- name: Build
run: bun run build
- name: Download previous build files
uses: actions/download-artifact@v4
with:
name: build-files
path: dist/
continue-on-error: true
- name: Upload build files
uses: actions/upload-artifact@v4
with:
name: build-files
path: .vitepress/dist/
retention-days: 90
overwrite: true
- name: Diff artifacts
run: rsync -ainc --delete .vitepress/dist dist/ | tee diff-list
- name: Upload diff file list
uses: actions/upload-artifact@v4
with:
name: diff-list
path: diff-list
overwrite: true
deploy:
needs: build
runs-on: ubuntu-latest
environment: production
env:
OSS_ACCESS_KEY_ID: ${{ secrets.OSS_ACCESS_KEY_ID }}
OSS_ACCESS_KEY_SECRET: ${{ secrets.OSS_ACCESS_KEY_SECRET }}
OSS_REGION: ${{ secrets.OSS_REGION }}
steps:
- name: Download build files
uses: actions/download-artifact@v4
with:
name: build-files
path: dist/
# see https://help.aliyun.com/zh/oss/developer-reference/ossutil-overview/
- name: Setup ossutil
run: |
VERSION=2.0.6-beta.01091200
FILE_NAME=ossutil-$VERSION-linux-amd64.zip
curl -o $FILE_NAME \
https://gosspublic.alicdn.com/ossutil/v2-beta/$VERSION/$FILE_NAME
unzip -j $FILE_NAME
chmod +x ossutil
./ossutil version
- name: Download diff list
uses: actions/download-artifact@v4
with:
name: diff-list
path: ./
- name: Deploy
run: |
BUCKET="oss://sustech-application"
grep '^\*' diff-list | sed 's/^\* //' \
| xargs -I{} ./ossutil rm -f "$BUCKET/{}"
grep '^>' diff-list | sed 's/^> //' \
| xargs -I{} ./ossutil cp -f dist/{} "$BUCKET/{}"