Skip to content

Commit f98f10f

Browse files
authored
增加测试环境
提交到这个分支会自动发布测试环境
1 parent 26066ce commit f98f10f

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

.github/workflows/devops-test.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: devops-test
2+
on:
3+
push:
4+
branches: [test]
5+
workflow_dispatch:
6+
jobs:
7+
build:
8+
name: Build
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
node-version: ['16.x']
13+
go-version: ['1.16']
14+
steps:
15+
- name: Check out branch
16+
uses: actions/checkout@v2
17+
- name: Sed Config
18+
env:
19+
PROD: ${{ secrets.PROD }}
20+
TESTING: ${{ secrets.TESTING }}
21+
shell: bash
22+
run: |
23+
git branch
24+
ls -l
25+
sed -i 's/${PROD}/${TESTING}/g' web/.env.production
26+
- name: Use Node.js ${{ matrix.node-version }}
27+
uses: actions/[email protected]
28+
with:
29+
node-version: ${{ matrix.node-version }}
30+
- name: Build-Node
31+
run: |
32+
cd web/ && yarn install && yarn run build
33+
- name: Use Go ${{ matrix.go-version }}
34+
uses: actions/setup-go@v1
35+
with:
36+
go-version: ${{ matrix.go-version }}
37+
- name: Build-go
38+
run: |
39+
cd server/ && go mod tidy && go build && mkdir ../web/ser && mv server ../web/ser/ && cd ../web/ser/ && ls -s
40+
- name: restart
41+
env:
42+
KEY: ${{ secrets.KEY }}
43+
HOST: ${{ secrets.HOST }}
44+
USER: ${{ secrets.USER }}
45+
PROT: ${{ secrets.PROT }}
46+
MKDIRTEST: ${{ secrets.MKDIRTEST }}
47+
run: |
48+
mkdir -p ~/.ssh/ && echo "$KEY" > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
49+
ssh-keyscan github.com >> ~/.ssh/known_hosts
50+
scp -P ${PROT} -o StrictHostKeyChecking=no -r web/dist/* ${USER}@${HOST}:${MKDIRTEST}dist/
51+
scp -P ${PROT} -o StrictHostKeyChecking=no -r web/ser/* ${USER}@${HOST}:${MKDIRTEST}
52+
ssh -p ${PROT} -o StrictHostKeyChecking=no ${USER}@${HOST} "cd ${MKDIRTEST}resource/ && rm -rf ${MKDIRTEST}resource/*"
53+
scp -P ${PROT} -o StrictHostKeyChecking=no -r server/resource/* ${USER}@${HOST}:${MKDIRTEST}resource/
54+
ssh -p ${PROT} -o StrictHostKeyChecking=no ${USER}@${HOST} "cd ${MKDIRTEST} && bash restart.sh > /dev/null 2>&1 &"

0 commit comments

Comments
 (0)