Skip to content

feat: incremental deployment #28

feat: incremental deployment

feat: incremental deployment #28

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 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: Parse diff list
run: |
touch delete-list update-list
grep '^\*' diff-list | sed 's/^\*.* dist\///' > delete-list
grep '^>' diff-list | sed 's/^>.* dist\///' > update-list
- name: Deploy
continue-on-error: true
run: |
BUCKET="oss://sustech-application"
./ossutil rm -f --files-from delete-list $BUCKET
./ossutil cp -f --files-from update-list ./ $BUCKET