releases-demo.yml 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # 将静态内容部署到 GitHub Pages 的简易工作流程
  2. name: RELEASES DEMO
  3. on:
  4. # 仅在推送到默认分支时触发工作流
  5. push:
  6. branches:
  7. - main
  8. # 这个选项可以使你手动在 Action tab 页面触发工作流
  9. workflow_dispatch:
  10. # 设置 GITHUB_TOKEN 的权限,以允许部署到 GitHub Pages。
  11. permissions:
  12. contents: read
  13. pages: write
  14. id-token: write
  15. # 允许一个并发的部署
  16. concurrency:
  17. group: 'pages'
  18. cancel-in-progress: true
  19. jobs:
  20. # 单次部署的工作描述
  21. deploy:
  22. environment:
  23. name: github-pages
  24. url: ${{ steps.deployment.outputs.page_url }}
  25. runs-on: ubuntu-latest
  26. steps:
  27. - name: Checkout
  28. uses: actions/checkout@v4
  29. - name: Set up Node
  30. uses: actions/setup-node@v4
  31. with:
  32. node-version: 20.x
  33. cache: 'npm'
  34. - name: Install dependencies and build
  35. env:
  36. BASE_PATH: '/${{ github.event.repository.name }}'
  37. run: |
  38. npm i
  39. npm run build
  40. - name: Setup Pages
  41. uses: actions/configure-pages@v4
  42. - name: Upload artifact
  43. uses: actions/upload-pages-artifact@v3
  44. with:
  45. # Upload dist folder
  46. path: 'build/'
  47. - name: Deploy to GitHub Pages
  48. id: deployment
  49. uses: actions/deploy-pages@v4