deploy.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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: Install pnpm
  60. uses: pnpm/action-setup@v2
  61. - name: use Node.js 16
  62. uses: actions/setup-node@v3
  63. with:
  64. node-version: '20.x'
  65. - name: Get yarn cache directory path
  66. id: yarn-cache-dir-path
  67. run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
  68. - name: Cache dependencies
  69. uses: actions/cache@v3
  70. with:
  71. path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
  72. key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  73. restore-keys: |
  74. ${{ runner.os }}-yarn-
  75. - name: Set SSH Environment
  76. env:
  77. DOCS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
  78. run: |
  79. mkdir -p ~/.ssh/
  80. echo "$ACTIONS_DEPLOY_KEY" > ~/.ssh/id_rsa
  81. chmod 600 ~/.ssh/id_rsa
  82. ssh-keyscan github.com > ~/.ssh/known_hosts
  83. chmod 700 ~/.ssh && chmod 600 ~/.ssh/*
  84. git config --global user.email "vbenadmin@163.com"
  85. git config --global user.name "vbenAdmin"
  86. - name: Build
  87. env:
  88. NODE_OPTIONS: '--max_old_space_size=4096'
  89. run: |
  90. pnpm install --no-frozen-lockfile
  91. pnpm build
  92. touch dist/.nojekyll
  93. cp dist/index.html dist/404.html
  94. - name: Delete gh-pages branch
  95. run: |
  96. git push origin --delete gh-pages
  97. - name: Deploy
  98. uses: peaceiris/actions-gh-pages@v3.9.0
  99. with:
  100. deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
  101. PUBLISH_BRANCH: gh-pages
  102. PUBLISH_DIR: ./dist
  103. CNAME: vben.vvbin.cn