name: Deploy Navigation Site on: push: branches: [ main ] workflow_dispatch: # 添加fork后的首次运行触发 fork: # 设置GITHUB_TOKEN的权限 permissions: contents: read pages: write id-token: write # 允许一个并发部署 concurrency: group: "pages" cancel-in-progress: true jobs: build: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 - name: Setup Node.js uses: actions/setup-node@v3 with: node-version: '16' cache: 'npm' - name: Install dependencies run: npm ci - name: Generate site run: npm run generate - name: Setup Pages uses: actions/configure-pages@v3 - name: Upload artifact uses: actions/upload-pages-artifact@v2 with: path: '.' - name: Create deployment guide issue if: github.event_name == 'fork' uses: actions/github-script@v6 with: script: | const issueBody = ` # 部署指南 请按照以下简单步骤完成网站部署: 1. 进入仓库设置 Settings -> Pages 2. 在 "Source" 下拉菜单中选择 "GitHub Actions" 3. 点击 Save 完成后,工作流将自动部署您的导航站点。 部署完成后,您可以在 Settings -> Pages 中找到您的网站地址。 `; await github.rest.issues.create({ owner: context.repo.owner, repo: context.repo.repo, title: '🚀 如何部署您的导航站点', body: issueBody, labels: ['documentation'] }); deploy: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest needs: build steps: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v2