build(deps-dev): bump the dev-dependencies-minor group across 1 directory with 10 updates #366
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Web3 Learning Platform | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| # 允许手动触发部署 | |
| workflow_dispatch: | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout 📁 | |
| uses: actions/checkout@v6 | |
| - name: Setup Node.js 🟢 | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install Dependencies 📦 | |
| # On pull_request (incl. Dependabot): use `npm install` so transient | |
| # lockfile drift doesn't block CI. On push to main / manual dispatch: | |
| # use strict `npm ci` to guarantee reproducible production builds. | |
| run: | | |
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| npm install --no-audit --no-fund | |
| else | |
| npm ci | |
| fi | |
| - name: Install Playwright Chromium 🎭 | |
| run: npx playwright install chromium | |
| - name: Run Tests 🧪 | |
| run: npm test | |
| - name: Check translation coverage | |
| run: node scripts/check-translation-coverage.mjs | |
| - name: Build Application 🔨 | |
| run: npm run build | |
| env: | |
| VITE_GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | |
| VITE_SITE_BASE_URL: https://bhbtc.xyz | |
| SITE_BASE_URL: https://bhbtc.xyz | |
| VITE_BASE_PATH: / | |
| VITE_GITHUB_USERNAME: ${{ vars.GITHUB_USERNAME || 'beihaili' }} | |
| VITE_GITHUB_REPO: ${{ vars.GITHUB_REPO || 'Get-Started-with-Web3' }} | |
| VITE_GITHUB_BRANCH: ${{ vars.GITHUB_BRANCH || 'main' }} | |
| - name: Deploy to GitHub Pages 🚀 | |
| if: github.ref == 'refs/heads/main' | |
| uses: peaceiris/actions-gh-pages@v4.1.0 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./dist | |
| cname: bhbtc.xyz | |
| - name: Upload PR build artifact 📦 | |
| if: github.event_name == 'pull_request' | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: pr-${{ github.event.pull_request.number }}-dist | |
| path: ./dist | |
| if-no-files-found: error | |
| retention-days: 7 | |
| - name: Comment PR with Preview Link 💬 | |
| if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| const marker = '<!-- pr-preview-artifact-link -->'; | |
| const runUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`; | |
| const body = [ | |
| marker, | |
| '📦 **构建成功!** PR 构建产物已上传,可从 Actions run 页面下载 `dist` artifact 进行本地预览。', | |
| '', | |
| `- 🔎 [打开本次 Actions run / 下载构建产物](${runUrl})`, | |
| '- 🚀 合并到 `main` 后会自动部署到生产环境。', | |
| ].join('\n'); | |
| const { owner, repo } = context.repo; | |
| const issue_number = context.issue.number; | |
| const comments = await github.rest.issues.listComments({ | |
| owner, | |
| repo, | |
| issue_number, | |
| per_page: 100, | |
| }); | |
| const previousComment = comments.data.find((comment) => ( | |
| comment.user?.type === 'Bot' && comment.body?.includes(marker) | |
| )); | |
| if (previousComment) { | |
| await github.rest.issues.updateComment({ | |
| owner, | |
| repo, | |
| comment_id: previousComment.id, | |
| body, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner, | |
| repo, | |
| issue_number, | |
| body, | |
| }); | |
| } | |
| - name: Output deployment URL 🌐 | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| echo "🚀 部署完成!" | |
| echo "📍 网站地址: https://bhbtc.xyz/" | |
| echo "⏰ 部署时间: $(date '+%Y-%m-%d %H:%M:%S')" |