From d0b64a456f15f6c836f07738c8437ece6769f9d7 Mon Sep 17 00:00:00 2001 From: dragooncjw <289056872@qq.com> Date: Thu, 6 Mar 2025 10:38:53 +0800 Subject: [PATCH] chore: deploy with github actions --- .github/workflows/deploy.yml | 69 ++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..b67cdac1 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,69 @@ +name: Deploy With Actions +on: + workflow_dispatch + +concurrency: + group: "gh-pages-branch-workflow" # 唯一标识符,确保只运行一个实例 + cancel-in-progress: false # 不取消正在运行的实例,后续触发需要等待当前实例完成 + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + pages: write + id-token: write + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 2 + - name: Check if branch is main + run: | + if [ "$GITHUB_REF" != "refs/heads/gh-pages" ]; then + echo "Not on gh-pages branch, exiting workflow." + exit 1 + fi + echo "On gh-pages branch, continuing workflow." + - name: Config Git User + run: | + git config --local user.name "dragooncjw" + git config --local user.email "289056872@qq.com" + - uses: actions/setup-node@v3 + with: + node-version: 18 + registry-url: 'https://registry.npmjs.org/' + - name: Rush Install + run: node common/scripts/install-run-rush.js install + - name: Rush build + run: node common/scripts/install-run-rush.js build + - name: Generate docs + run: | + cd apps/docs + npm run docs + - name: Copy auto-docs to en + run: cp -r apps/docs/src/zh/auto-docs apps/docs/src/en/auto-docs + - name: Build Doc site + run: | + cd apps/docs + npm run build + - name: Replace docs + run: | + rm -rf docs + mv apps/docs/doc_build docs + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: docs + + deploy: + needs: build + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 +