-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (72 loc) · 2.83 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
on:
push:
tags:
- 'v*'
name: gateway ci
jobs:
build-and-deploy:
name: Build & Deploy
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v4
- name: Replace secrets for aliyun_oss.yaml
run: |
sed -i "s/OSS_ACCESS_ENDPOINT/${{ secrets.OSS_ACCESS_ENDPOINT }}/g" ./conf/aliyun_oss.yaml
sed -i "s/OSS_ACCESS_KEY_ID/${{ secrets.OSS_ACCESS_KEY_ID }}/g" ./conf/aliyun_oss.yaml
sed -i "s/OSS_ACCESS_KEY_SECRET/${{ secrets.OSS_ACCESS_KEY_SECRET }}/g" ./conf/aliyun_oss.yaml
- name: Replace secrets for data_platform.yaml
run: |
sed -i "s/DATA_PLATFORM_ENDPOINT/${{ secrets.DATA_PLATFORM_ENDPOINT }}/g" ./conf/data_platform.yaml
- name: Replace secrets for mysql.yaml
run: |
sed -i "s/DB_IP/${{ secrets.DB_IP }}/g" ./conf/mysql.yaml
sed -i "s/DB_PORT/${{ secrets.DB_PORT }}/g" ./conf/mysql.yaml
sed -i "s/DB_USER/${{ secrets.DB_USER }}/g" ./conf/mysql.yaml
sed -i "s/DB_PASSWD/${{ secrets.DB_PASSWD }}/g" ./conf/mysql.yaml
- name: Replace secrets for wx_payment.yaml
run: |
sed -i "s/TOKEN_WX_APPID/${{ secrets.TOKEN_WX_APPID }}/g" ./conf/wx_payment.yaml
sed -i "s/TOKEN_WX_MCHID/${{ secrets.TOKEN_WX_MCHID }}/g" ./conf/wx_payment.yaml
sed -i "s/TOKEN_WX_MCH_APIV3/${{ secrets.TOKEN_WX_MCH_APIV3 }}/g" ./conf/wx_payment.yaml
sed -i "s/TOKEN_WX_SECRET/${{ secrets.TOKEN_WX_SECRET }}/g" ./conf/wx_payment.yaml
sed -i "s/TOKEN_WX_SERIAL_NO/${{ secrets.TOKEN_WX_SERIAL_NO }}/g" ./conf/wx_payment.yaml
- name: Build
run: |
go build
mkdir -p output/bin output/conf
mv ./grpc-gateway output/bin/
mv ./conf/* output/conf/
- name: Backup old version
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.SERVER_PORT }}
script: |
mv ${{ secrets.DEPLOY_PATH }} ${{ secrets.DEPLOY_PATH }}.$(date +%Y%m%d_%H%M)
- name: Deploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.SERVER_PORT }}
source: ./output/*
target: ${{ secrets.DEPLOY_PATH }}
strip_components: 1
restart:
name: Restart(TODO)
needs: build-and-deploy
runs-on: ubuntu-latest
steps:
- uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.SERVER_PORT }}
script: |
cd ${{ secrets.DEPLOY_PATH }}
ls -al