feat: 新手引导系统 #342
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: Preview on Github Page | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "src/**" | |
| - "public/**" | |
| - "index.html" | |
| - "package.json" | |
| - "vite.config.ts" | |
| - ".github/workflows/preview.yaml" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_deploy: ${{ steps.check_iteration.outputs.changed }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check betaIteration change | |
| id: check_iteration | |
| run: | | |
| # 获取当前 betaIteration 值 | |
| CURRENT=$(grep -oP 'betaIteration:\s*\K\d+' src/stores/configStore.ts) | |
| echo "Current betaIteration: $CURRENT" | |
| # 如果 betaIteration 小于等于 0,仅校验不部署 | |
| if [ "$CURRENT" -le "0" ]; then | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| echo "ℹ️ betaIteration is $CURRENT (<=0), will skip deployment (validate only)" | |
| exit 0 | |
| fi | |
| # 获取上一次 commit 的 betaIteration 值 | |
| git fetch origin gh-pages || echo "No gh-pages branch yet" | |
| PREVIOUS=$(git show HEAD~1:src/stores/configStore.ts 2>/dev/null | grep -oP 'betaIteration:\s*\K\d+' || echo "0") | |
| echo "Previous betaIteration: $PREVIOUS" | |
| # 比较是否有变化 | |
| if [ "$CURRENT" != "$PREVIOUS" ]; then | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| echo "✅ betaIteration changed from $PREVIOUS to $CURRENT, will deploy" | |
| else | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| echo "ℹ️ betaIteration unchanged ($CURRENT), will skip deployment" | |
| fi | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: yarn | |
| - name: Setup Pages | |
| if: steps.check_iteration.outputs.changed == 'true' | |
| uses: actions/configure-pages@v4 | |
| - name: Install dependencies | |
| run: yarn install | |
| - name: Build with Vite | |
| run: yarn build --mode preview | |
| - name: Upload artifact | |
| if: steps.check_iteration.outputs.changed == 'true' | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./dist | |
| deploy: | |
| if: needs.build.outputs.should_deploy == 'true' | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| needs: build | |
| runs-on: ubuntu-latest | |
| name: Deploy | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |