main.yml 1.6 KB

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