main.yml 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. name: build and deploy
  2. # v3 分支 push 代码的时候触发
  3. on:
  4. push:
  5. branches:
  6. - v3
  7. jobs:
  8. push-to-gh-pages:
  9. if: "contains(github.event.head_commit.message, '[release]')"
  10. runs-on: ubuntu-latest
  11. steps:
  12. - name: Checkout
  13. uses: actions/checkout@v2
  14. - name: use Node.js 16
  15. uses: actions/setup-node@v2.1.2
  16. with:
  17. node-version: '16.x'
  18. - name: Get yarn cache
  19. id: yarn-cache
  20. run: echo "::set-output name=dir::$(yarn cache dir)"
  21. - name: Cache dependencies
  22. uses: actions/cache@v2
  23. with:
  24. path: ${{ steps.yarn-cache.outputs.dir }}
  25. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  26. restore-keys: |
  27. ${{ runner.os }}-yarn-
  28. - name: Set SSH Environment
  29. env:
  30. DOCS_DEPLOY_KEY: ${{ secrets.ACCESS_TOKEN }}
  31. run: |
  32. mkdir -p ~/.ssh/
  33. echo "$ACCESS_TOKEN" > ~/.ssh/id_rsa
  34. chmod 600 ~/.ssh/id_rsa
  35. ssh-keyscan github.com > ~/.ssh/known_hosts
  36. chmod 700 ~/.ssh && chmod 600 ~/.ssh/*
  37. git config --local user.email "502431556@qq.com"
  38. git config --local user.name "kailong321200875"
  39. - name: Delete gh-pages branch
  40. run: |
  41. git push origin --delete gh-pages
  42. - name: Build
  43. run: |
  44. yarn install
  45. yarn run build
  46. touch dist/.nojekyll
  47. cp dist/index.html dist/404.html
  48. - name: Deploy
  49. uses: peaceiris/actions-gh-pages@v2.5.0
  50. env:
  51. ACTIONS_DEPLOY_KEY: ${{secrets.ACCESS_TOKEN}}
  52. PUBLISH_BRANCH: gh-pages
  53. PUBLISH_DIR: ./dist-pro
  54. with:
  55. forceOrphan: true