|
| 1 | +name: Build and Deploy to Gitee Pages |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +concurrency: |
| 9 | + group: deploy-gitee-${{ github.ref }} |
| 10 | + cancel-in-progress: true |
| 11 | + |
| 12 | +jobs: |
| 13 | + build-and-deploy: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + if: github.repository == 'doocs/md' |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v5 |
| 19 | + with: |
| 20 | + fetch-depth: 0 # 获取完整历史,便于推送到新分支 |
| 21 | + |
| 22 | + - name: Set up node |
| 23 | + uses: actions/setup-node@v6 |
| 24 | + with: |
| 25 | + node-version: 22 |
| 26 | + |
| 27 | + - name: Setup pnpm |
| 28 | + uses: pnpm/action-setup@v4 |
| 29 | + with: |
| 30 | + version: 10 |
| 31 | + |
| 32 | + - name: Install dependencies |
| 33 | + run: pnpm install |
| 34 | + |
| 35 | + - name: Build project |
| 36 | + run: pnpm web build |
| 37 | + |
| 38 | + - name: Deploy to GitHub Pages |
| 39 | + uses: peaceiris/actions-gh-pages@v4 |
| 40 | + with: |
| 41 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + publish_dir: ./apps/web/dist |
| 43 | + publish_branch: dist |
| 44 | + force_orphan: true |
| 45 | + user_name: 'github-actions[bot]' |
| 46 | + user_email: 'github-actions[bot]@users.noreply.github.com' |
| 47 | + commit_message: 'Deploy: ${{ github.sha }}' |
| 48 | + |
| 49 | + - name: Sync to Gitee |
| 50 | + uses: Yikun/hub-mirror-action@v1.4 |
| 51 | + with: |
| 52 | + src: github/doocs |
| 53 | + dst: gitee/doocs |
| 54 | + dst_key: ${{ secrets.GITEE_RSA_PRIVATE_KEY }} |
| 55 | + dst_token: ${{ secrets.GITEE_TOKEN }} |
| 56 | + static_list: "md" |
| 57 | + force_update: true |
| 58 | + debug: true |
| 59 | + |
| 60 | + - name: Deploy Gitee Pages |
| 61 | + uses: yanglbme/gitee-pages-action@main |
| 62 | + with: |
| 63 | + gitee-username: ${{ secrets.GITEE_USERNAME }} |
| 64 | + gitee-password: ${{ secrets.GITEE_PASSWORD }} |
| 65 | + gitee-repo: doocs/md |
| 66 | + branch: dist |
| 67 | + |
| 68 | + - name: Deployment Summary |
| 69 | + run: | |
| 70 | + echo "✅ Build completed successfully!" |
| 71 | + echo "📦 Artifacts pushed to dist branch" |
| 72 | + echo "🔄 Synced to Gitee repository" |
| 73 | + echo "🚀 Gitee Pages deployed" |
| 74 | + echo "" |
| 75 | + echo "Gitee Pages: https://doocs.gitee.io/md/" |
0 commit comments