main.yml 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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.ACTIONS_DEPLOY_KEY }}
  30. run: |
  31. mkdir -p ~/.ssh/
  32. echo "$ACTIONS_DEPLOY_KEY" > ~/.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: Build
  39. run: |
  40. yarn install
  41. yarn run build:pro
  42. - name: Deploy
  43. uses: peaceiris/actions-gh-pages@v3
  44. with:
  45. deploy_key: ${{secrets.ACTIONS_DEPLOY_KEY}}
  46. publish_branch: gh-pages
  47. publish_dir: ./dist-pro
  48. keep_files: true