Merge pull request #2 from ShiSeAB/add-exercise-solution #7
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 Exercises (Simple) | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'exercises/**' | |
| workflow_dispatch: # 允许手动触发 | |
| # 设置权限以允许部署到 GitHub Pages | |
| permissions: | |
| contents: write # 允许推送到 gh-pages 分支 | |
| pages: write | |
| id-token: write | |
| jobs: | |
| # 检测并部署 | |
| deploy: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Check for exercises changes | |
| uses: dorny/paths-filter@v3 | |
| id: filter | |
| with: | |
| filters: | | |
| exercises: | |
| - 'exercises/**' | |
| - name: Deploy to GitHub Pages | |
| if: steps.filter.outputs.exercises == 'true' || github.event_name == 'workflow_dispatch' | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./exercises | |
| enable_jekyll: false | |
| cname: false # 如果有自定义域名,在这里设置 | |
| - name: Deployment summary | |
| if: steps.filter.outputs.exercises == 'true' || github.event_name == 'workflow_dispatch' | |
| run: | | |
| echo "✅ Exercises 已成功部署到 GitHub Pages!" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "📚 访问地址: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/" >> $GITHUB_STEP_SUMMARY | |