JinMao
2022-11-16 d01c1b4d054f98d6876e06ff544d4dd7c0d267f5
.github/workflows/deploy.yml
@@ -6,79 +6,78 @@
      - main
jobs:
  push-to-ftp:
    if: "contains(github.event.head_commit.message, '[deploy]')"
  # push-to-ftp:
  #   if: "contains(github.event.head_commit.message, '[deploy]')"
  #   runs-on: ubuntu-latest
  #   steps:
  #     - name: Checkout
  #       uses: actions/checkout@v2
  #     - name: Sed Config Base
  #       shell: bash
  #       run: |
  #         sed -i  's#VITE_PUBLIC_PATH\s*=.*#VITE_PUBLIC_PATH = /next/#g' ./.env.production
  #         sed -i  "s#VITE_BUILD_COMPRESS\s*=.*#VITE_BUILD_COMPRESS = 'gzip'#g" ./.env.production
  #         cat ./.env.production
  #     - name: use Node.js 14
  #       uses: actions/setup-node@v2.1.2
  #       with:
  #         node-version: '14.x'
  #     - name: Get yarn cache
  #       id: yarn-cache
  #       run: echo "::set-output name=dir::$(yarn cache dir)"
  #     - name: Cache dependencies
  #       uses: actions/cache@v2
  #       with:
  #         path: ${{ steps.yarn-cache.outputs.dir }}
  #         key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
  #         restore-keys: |
  #           ${{ runner.os }}-yarn-
  #     - name: Build
  #       run: |
  #         yarn install
  #         yarn run build
  #     - name: Deploy
  #       uses: SamKirkland/FTP-Deploy-Action@2.0.0
  #       env:
  #         FTP_SERVER: ${{ secrets.FTP_SERVER }}
  #         FTP_USERNAME: ${{ secrets.FTP_USERNAME }}
  #         FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }}
  #         METHOD: sftp
  #         PORT: ${{ secrets.FTP_PORT }}
  #         LOCAL_DIR: dist
  #         REMOTE_DIR: /srv/www/vben-admin
  #         ARGS: --delete --verbose --parallel=80
  push-to-gh-pages:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        uses: actions/checkout@v3
      - name: Sed Config Base
        shell: bash
        run: |
          sed -i  's#VITE_PUBLIC_PATH\s*=.*#VITE_PUBLIC_PATH = /next/#g' ./.env.production
          sed -i  "s#VITE_BUILD_COMPRESS\s*=.*#VITE_BUILD_COMPRESS = 'gzip'#g" ./.env.production
          sed -i  "s#VITE_DROP_CONSOLE\s*=.*#VITE_DROP_CONSOLE = true#g" ./.env.production
          cat ./.env.production
      - name: use Node.js 14
        uses: actions/setup-node@v2.1.2
      - name: use Node.js 16
        uses: actions/setup-node@v3
        with:
          node-version: '14.x'
          node-version: '16.x'
      - name: Get yarn cache
        id: yarn-cache
        run: echo "::set-output name=dir::$(yarn cache dir)"
      - name: Cache dependencies
        uses: actions/cache@v2
        with:
          path: ${{ steps.yarn-cache.outputs.dir }}
          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-yarn-
      - name: Build
        run: |
          yarn install
          yarn run build
      - name: Deploy
        uses: SamKirkland/FTP-Deploy-Action@2.0.0
        env:
          FTP_SERVER: ${{ secrets.FTP_SERVER }}
          FTP_USERNAME: ${{ secrets.FTP_USERNAME }}
          FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }}
          METHOD: sftp
          PORT: ${{ secrets.FTP_PORT }}
          LOCAL_DIR: dist
          REMOTE_DIR: /srv/www/vben-admin
          ARGS: --delete --verbose --parallel=80
  push-to-gh-page:
    if: "contains(github.event.head_commit.message, '[deploy]')"
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Sed Config Base
        shell: bash
        run: |
          sed -i  's#VITE_PUBLIC_PATH\s*=.*#VITE_PUBLIC_PATH = /vue-vben-admin/#g' ./.env.production
          sed -i  "s#VITE_BUILD_COMPRESS\s*=.*#VITE_BUILD_COMPRESS = 'gzip'#g" ./.env.production
          cat ./.env.production
      - name: use Node.js 14
        uses: actions/setup-node@v2.1.2
        with:
          node-version: '14.x'
      - name: Get yarn cache
        id: yarn-cache
        run: echo "::set-output name=dir::$(yarn cache dir)"
      - name: Cache dependencies
        uses: actions/cache@v2
        uses: actions/cache@v3
        with:
          path: ${{ steps.yarn-cache.outputs.dir }}
          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
@@ -97,10 +96,6 @@
          git config --global user.email "vbenadmin@163.com"
          git config --global user.name "vbenAdmin"
      - name: Delete gh-pages branch
        run: |
          git push origin --delete gh-pages
      - name: Build
        run: |
          yarn install
@@ -108,11 +103,19 @@
          touch dist/.nojekyll
          cp dist/index.html dist/404.html
      - name: Delete gh-pages branch
        run: |
          git push origin --delete gh-pages
      - name: Deploy
        uses: peaceiris/actions-gh-pages@v2.5.0
        uses: peaceiris/actions-gh-pages@v3
        env:
          ACTIONS_DEPLOY_KEY: ${{secrets.ACTIONS_DEPLOY_KEY}}
          PUBLISH_BRANCH: gh-pages
          PUBLISH_DIR: ./dist
          cname: vben.vvbin.cn
        with:
          forceOrphan: true