Add Github Actions workflow #1
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 to GitHub Pages | |
| on: | |
| # 每次推送到 main 分支时触发 | |
| push: | |
| branches: [ main ] | |
| # 允许在 Actions 页面手动触发 | |
| workflow_dispatch: | |
| # 设置权限,允许 Actions 修改 GitHub Pages | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # 这是一个并发组配置,防止同时推两次导致冲突 | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout your repository using git | |
| uses: actions/checkout@v4 | |
| - name: Install, build, and upload your site | |
| uses: withastro/action@v2 | |
| # with: | |
| # path: . # 如果你的 astro 项目不在根目录,可以在这里修改 | |
| # package-manager: npm # 通常会自动检测,如果报错可以手动指定 | |
| 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@v4 |