devops.yml 1.9 KB
Newer Older
T
tscuite 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
name: devops
on:
  push:
    tags:
      - v*
  workflow_dispatch:
jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: ['16.x']
        go-version: ['1.16']
    steps:
      - name: Check out branch
        uses: actions/checkout@v2
      - name: Sed Config
        shell: bash
        run: |
          git branch 
          ls -l
T
tscuite 已提交
23
          sed -i 's/${basePath}:${basePort}/${basePath}/g' web/src/view/systemTools/formCreate/index.vue
T
tscuite 已提交
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v2.1.2
        with:
          node-version: ${{ matrix.node-version }}
      - name: Build-Node
        run: |
          cd web/ && yarn install && yarn run build
      - name: Use Go ${{ matrix.go-version }}
        uses: actions/setup-go@v1
        with:
          go-version: ${{ matrix.go-version }}
      - name: Build-go
        run: |
          cd server/ && go mod tidy && go build && mkdir ../web/ser && mv server ../web/ser/ && cd ../web/ser/ && ls -s 
      - name: restart
        env:
          KEY: ${{ secrets.KEY }}
          HOST: ${{ secrets.HOST }}
          USER: ${{ secrets.USER }}
          PROT: ${{ secrets.PROT }}
          MKDIR: ${{ secrets.MKDIR }}
        run: |
          mkdir -p ~/.ssh/ && echo "$KEY" > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
          ssh-keyscan github.com >> ~/.ssh/known_hosts
          scp -P ${PROT} -o StrictHostKeyChecking=no -r web/dist/* ${USER}@${HOST}:${MKDIR}dist/
          scp -P ${PROT} -o StrictHostKeyChecking=no -r web/ser/* ${USER}@${HOST}:${MKDIR}
50 51
          ssh -p ${PROT} -o StrictHostKeyChecking=no ${USER}@${HOST} "cd ${MKDIR}resource/ && rm -rf ${MKDIR}resource/*"
          scp -P ${PROT} -o StrictHostKeyChecking=no -r server/resource/* ${USER}@${HOST}:${MKDIR}resource/
T
tscuite 已提交
52
          ssh -p ${PROT} -o StrictHostKeyChecking=no ${USER}@${HOST} "cd ${MKDIR} && bash restart.sh > /dev/null  2>&1 &"