From b544116c06fd842cfc46baf8d4a885d5b2e42eba Mon Sep 17 00:00:00 2001 From: boybook Date: Mon, 24 Mar 2025 23:51:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=87=B3=E9=98=BF=E9=87=8C?= =?UTF-8?q?=E4=BA=91OSS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deployOSS.yml | 56 +++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/deployOSS.yml diff --git a/.github/workflows/deployOSS.yml b/.github/workflows/deployOSS.yml new file mode 100644 index 00000000..fee9f5b0 --- /dev/null +++ b/.github/workflows/deployOSS.yml @@ -0,0 +1,56 @@ +name: Deploy VitePress to AliYun OSS + +on: + # 每次推送到main分支时触发部署 + push: + branches: [main] + # 允许手动触发工作流 + workflow_dispatch: + +# 设置GITHUB_TOKEN的权限 +permissions: + contents: read + +jobs: + # 构建工作 + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + lfs: true + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: npm + + - name: Setup Pages + uses: actions/configure-pages@v4 + + - name: Install dependencies + run: npm ci + + - name: Build with VitePress + run: npm run docs:build + + # docs/.vitepress/dist + + - name: Install OSSUtil + run: | + curl -o /tmp/ossutil64 https://gosspublic.alicdn.com/ossutil/1.7.8/ossutil64 + chmod +x /tmp/ossutil64 + sudo mv /tmp/ossutil64 /usr/local/bin/ossutil + + - name: Upload to Aliyun OSS + env: + OSS_ACCESS_KEY_ID: ${{ secrets.ALIYUN_ACCESS_KEY_ID }} + OSS_ACCESS_KEY_SECRET: ${{ secrets.ALIYUN_ACCESS_KEY_SECRET }} + OSS_BUCKET: ec-mcwiki + OSS_REGION: oss-cn-hangzhou + run: | + ossutil config -e ${OSS_REGION}.aliyuncs.com -i ${OSS_ACCESS_KEY_ID} -k ${OSS_ACCESS_KEY_SECRET} + ossutil cp -r ./docs/.vitepress/dist oss://${OSS_BUCKET}/ --force \ No newline at end of file