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