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. runs-on: ubuntu-latest
  50. steps:
  51. - name: Checkout
  52. uses: actions/checkout@v3
  53. - name: Sed Config Base
  54. shell: bash
  55. run: |
  56. sed -i "s#VITE_BUILD_COMPRESS\s*=.*#VITE_BUILD_COMPRESS = 'gzip'#g" ./.env.production
  57. sed -i "s#VITE_DROP_CONSOLE\s*=.*#VITE_DROP_CONSOLE = true#g" ./.env.production
  58. cat ./.env.production
  59. - name: use Node.js 16
  60. uses: actions/setup-node@v3
  61. with:
  62. node-version: '16.x'
  63. - name: Get yarn cache directory path
  64. id: yarn-cache-dir-path
  65. run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
  66. - name: Cache dependencies
  67. uses: actions/cache@v3
  68. with:
  69. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  70. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  71. restore-keys: |
  72. ${{ runner.os }}-yarn-
  73. - name: Set SSH Environment
  74. env:
  75. DOCS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
  76. run: |
  77. mkdir -p ~/.ssh/
  78. echo "$ACTIONS_DEPLOY_KEY" > ~/.ssh/id_rsa
  79. chmod 600 ~/.ssh/id_rsa
  80. ssh-keyscan github.com > ~/.ssh/known_hosts
  81. chmod 700 ~/.ssh && chmod 600 ~/.ssh/*
  82. git config --global user.email "vbenadmin@163.com"
  83. git config --global user.name "vbenAdmin"
  84. - name: Build
  85. env:
  86. NODE_OPTIONS: '--max_old_space_size=4096'
  87. run: |
  88. yarn install
  89. yarn run build
  90. touch dist/.nojekyll
  91. cp dist/index.html dist/404.html
  92. - name: Delete gh-pages branch
  93. run: |
  94. git push origin --delete gh-pages
  95. - name: Deploy
  96. uses: peaceiris/actions-gh-pages@v3.9.0
  97. with:
  98. deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
  99. PUBLISH_BRANCH: gh-pages
  100. PUBLISH_DIR: ./dist
  101. CNAME: vben.vvbin.cn