deploy.yml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. name: deploy
  2. on:
  3. push:
  4. branches:
  5. - main
  6. jobs:
  7. # push-to-ftp:
  8. # if: "contains(github.event.head_commit.message, '[deploy]')"
  9. # runs-on: ubuntu-latest
  10. # steps:
  11. # - name: Checkout
  12. # uses: actions/checkout@v2
  13. # - name: Sed Config Base
  14. # shell: bash
  15. # run: |
  16. # sed -i 's#VITE_PUBLIC_PATH\s*=.*#VITE_PUBLIC_PATH = /next/#g' ./.env.production
  17. # sed -i "s#VITE_BUILD_COMPRESS\s*=.*#VITE_BUILD_COMPRESS = 'gzip'#g" ./.env.production
  18. # cat ./.env.production
  19. # - name: use Node.js 14
  20. # uses: actions/setup-node@v2.1.2
  21. # with:
  22. # node-version: '14.x'
  23. # - name: Get yarn cache
  24. # id: yarn-cache
  25. # run: echo "::set-output name=dir::$(yarn cache dir)"
  26. # - name: Cache dependencies
  27. # uses: actions/cache@v2
  28. # with:
  29. # path: ${{ steps.yarn-cache.outputs.dir }}
  30. # key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  31. # restore-keys: |
  32. # ${{ runner.os }}-yarn-
  33. # - name: Build
  34. # run: |
  35. # yarn install
  36. # yarn run build
  37. # - name: Deploy
  38. # uses: SamKirkland/FTP-Deploy-Action@2.0.0
  39. # env:
  40. # FTP_SERVER: ${{ secrets.FTP_SERVER }}
  41. # FTP_USERNAME: ${{ secrets.FTP_USERNAME }}
  42. # FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }}
  43. # METHOD: sftp
  44. # PORT: ${{ secrets.FTP_PORT }}
  45. # LOCAL_DIR: dist
  46. # REMOTE_DIR: /srv/www/vben-admin
  47. # ARGS: --delete --verbose --parallel=80
  48. push-to-gh-pages:
  49. if: "contains(github.event.head_commit.message, '[release]')"
  50. runs-on: ubuntu-latest
  51. steps:
  52. - name: Checkout
  53. uses: actions/checkout@v2
  54. - name: Sed Config Base
  55. shell: bash
  56. run: |
  57. sed -i 's#VITE_PUBLIC_PATH\s*=.*#VITE_PUBLIC_PATH = /vue-vben-admin/#g' ./.env.production
  58. sed -i "s#VITE_BUILD_COMPRESS\s*=.*#VITE_BUILD_COMPRESS = 'gzip'#g" ./.env.production
  59. cat ./.env.production
  60. - name: use Node.js 14
  61. uses: actions/setup-node@v2.1.2
  62. with:
  63. node-version: '14.x'
  64. - name: Get yarn cache
  65. id: yarn-cache
  66. run: echo "::set-output name=dir::$(yarn cache dir)"
  67. - name: Cache dependencies
  68. uses: actions/cache@v2
  69. with:
  70. path: ${{ steps.yarn-cache.outputs.dir }}
  71. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  72. restore-keys: |
  73. ${{ runner.os }}-yarn-
  74. - name: Set SSH Environment
  75. env:
  76. DOCS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
  77. run: |
  78. mkdir -p ~/.ssh/
  79. echo "$ACTIONS_DEPLOY_KEY" > ~/.ssh/id_rsa
  80. chmod 600 ~/.ssh/id_rsa
  81. ssh-keyscan github.com > ~/.ssh/known_hosts
  82. chmod 700 ~/.ssh && chmod 600 ~/.ssh/*
  83. git config --local user.email "vbenadmin@163.com"
  84. git config --local user.name "vbenAdmin"
  85. - name: Delete gh-pages branch
  86. run: |
  87. git push origin --delete gh-pages
  88. - name: Build
  89. run: |
  90. yarn install
  91. yarn run build
  92. touch dist/.nojekyll
  93. cp dist/index.html dist/404.html
  94. - name: Deploy
  95. uses: peaceiris/actions-gh-pages@v2.5.0
  96. env:
  97. ACTIONS_DEPLOY_KEY: ${{secrets.ACTIONS_DEPLOY_KEY}}
  98. PUBLISH_BRANCH: gh-pages
  99. PUBLISH_DIR: ./dist
  100. with:
  101. forceOrphan: true