JinMao
2022-11-16 d01c1b4d054f98d6876e06ff544d4dd7c0d267f5
提交 | 用户 | age
c303ec 1 name: deploy
V 2
3 on:
4   push:
5     branches:
6       - main
7
8 jobs:
ee5fb2 9   # push-to-ftp:
V 10   #   if: "contains(github.event.head_commit.message, '[deploy]')"
11   #   runs-on: ubuntu-latest
12   #   steps:
13   #     - name: Checkout
14   #       uses: actions/checkout@v2
8ccf77 15
ee5fb2 16   #     - name: Sed Config Base
V 17   #       shell: bash
18   #       run: |
19   #         sed -i  's#VITE_PUBLIC_PATH\s*=.*#VITE_PUBLIC_PATH = /next/#g' ./.env.production
20   #         sed -i  "s#VITE_BUILD_COMPRESS\s*=.*#VITE_BUILD_COMPRESS = 'gzip'#g" ./.env.production
21   #         cat ./.env.production
8ccf77 22
ee5fb2 23   #     - name: use Node.js 14
V 24   #       uses: actions/setup-node@v2.1.2
25   #       with:
26   #         node-version: '14.x'
8ccf77 27
ee5fb2 28   #     - name: Get yarn cache
V 29   #       id: yarn-cache
30   #       run: echo "::set-output name=dir::$(yarn cache dir)"
8ccf77 31
ee5fb2 32   #     - name: Cache dependencies
V 33   #       uses: actions/cache@v2
34   #       with:
35   #         path: ${{ steps.yarn-cache.outputs.dir }}
36   #         key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
37   #         restore-keys: |
38   #           ${{ runner.os }}-yarn-
8ccf77 39
ee5fb2 40   #     - name: Build
V 41   #       run: |
42   #         yarn install
43   #         yarn run build
8ccf77 44
ee5fb2 45   #     - name: Deploy
V 46   #       uses: SamKirkland/FTP-Deploy-Action@2.0.0
47   #       env:
48   #         FTP_SERVER: ${{ secrets.FTP_SERVER }}
49   #         FTP_USERNAME: ${{ secrets.FTP_USERNAME }}
50   #         FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }}
51   #         METHOD: sftp
52   #         PORT: ${{ secrets.FTP_PORT }}
53   #         LOCAL_DIR: dist
54   #         REMOTE_DIR: /srv/www/vben-admin
55   #         ARGS: --delete --verbose --parallel=80
8ccf77 56
5cc948 57   push-to-gh-pages:
8ccf77 58     runs-on: ubuntu-latest
V 59     steps:
60       - name: Checkout
cb2898 61         uses: actions/checkout@v3
8ccf77 62
V 63       - name: Sed Config Base
64         shell: bash
65         run: |
66           sed -i  "s#VITE_BUILD_COMPRESS\s*=.*#VITE_BUILD_COMPRESS = 'gzip'#g" ./.env.production
476b2b 67           sed -i  "s#VITE_DROP_CONSOLE\s*=.*#VITE_DROP_CONSOLE = true#g" ./.env.production
8ccf77 68           cat ./.env.production
V 69
c69996 70       - name: use Node.js 16
cb2898 71         uses: actions/setup-node@v3
8ccf77 72         with:
c69996 73           node-version: '16.x'
8ccf77 74
V 75       - name: Get yarn cache
76         id: yarn-cache
77         run: echo "::set-output name=dir::$(yarn cache dir)"
78
79       - name: Cache dependencies
cb2898 80         uses: actions/cache@v3
8ccf77 81         with:
V 82           path: ${{ steps.yarn-cache.outputs.dir }}
83           key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
84           restore-keys: |
85             ${{ runner.os }}-yarn-
86
87       - name: Set SSH Environment
88         env:
908a2f 89           DOCS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
8ccf77 90         run: |
V 91           mkdir -p ~/.ssh/
908a2f 92           echo "$ACTIONS_DEPLOY_KEY" > ~/.ssh/id_rsa
8ccf77 93           chmod 600 ~/.ssh/id_rsa
V 94           ssh-keyscan github.com > ~/.ssh/known_hosts
95           chmod 700 ~/.ssh && chmod 600 ~/.ssh/*
93d465 96           git config --global user.email "vbenadmin@163.com"
V 97           git config --global user.name "vbenAdmin"
8ccf77 98
V 99       - name: Build
100         run: |
101           yarn install
102           yarn run build
c6f9b0 103           touch dist/.nojekyll
V 104           cp dist/index.html dist/404.html
c303ec 105
057b82 106       - name: Delete gh-pages branch
J 107         run: |
108           git push origin --delete gh-pages
109
c303ec 110       - name: Deploy
d01c1b 111         uses: peaceiris/actions-gh-pages@v3
31f489 112         env:
908a2f 113           ACTIONS_DEPLOY_KEY: ${{secrets.ACTIONS_DEPLOY_KEY}}
c303ec 114           PUBLISH_BRANCH: gh-pages
448d21 115           PUBLISH_DIR: ./dist
d01c1b 116           cname: vben.vvbin.cn
31f489 117         with:
V 118           forceOrphan: true
640ac6 119
057b82 120
J 121