From f98f10f869cdbd7db755ca4455945bd5d63c2d16 Mon Sep 17 00:00:00 2001 From: tscuite <64051240+tscuite@users.noreply.github.com> Date: Thu, 30 Dec 2021 10:59:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B5=8B=E8=AF=95=E7=8E=AF?= =?UTF-8?q?=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 提交到这个分支会自动发布测试环境 --- .github/workflows/devops-test.yaml | 54 ++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/devops-test.yaml diff --git a/.github/workflows/devops-test.yaml b/.github/workflows/devops-test.yaml new file mode 100644 index 00000000..a813732f --- /dev/null +++ b/.github/workflows/devops-test.yaml @@ -0,0 +1,54 @@ +name: devops-test +on: + push: + branches: [test] + 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 + env: + PROD: ${{ secrets.PROD }} + TESTING: ${{ secrets.TESTING }} + shell: bash + run: | + git branch + ls -l + sed -i 's/${PROD}/${TESTING}/g' web/.env.production + - 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 }} + MKDIRTEST: ${{ secrets.MKDIRTEST }} + 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}:${MKDIRTEST}dist/ + scp -P ${PROT} -o StrictHostKeyChecking=no -r web/ser/* ${USER}@${HOST}:${MKDIRTEST} + ssh -p ${PROT} -o StrictHostKeyChecking=no ${USER}@${HOST} "cd ${MKDIRTEST}resource/ && rm -rf ${MKDIRTEST}resource/*" + scp -P ${PROT} -o StrictHostKeyChecking=no -r server/resource/* ${USER}@${HOST}:${MKDIRTEST}resource/ + ssh -p ${PROT} -o StrictHostKeyChecking=no ${USER}@${HOST} "cd ${MKDIRTEST} && bash restart.sh > /dev/null 2>&1 &"