deploy.yml 3.6 KB

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