-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (98 loc) · 5.14 KB
/
push.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: Deploy to Server
on:
push:
branches:
- staging
paths:
- 'backend/**'
- 'backend-ausdce/**'
- 'backend-dai/**'
- 'backend-usdc/**'
- 'backend-usdt/**'
- 'backend-wbtc/**'
- 'backend-weth/**'
- 'backend-wnt/**'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Filter Changed Files
id: filter
uses: dorny/paths-filter@v2
with:
filters: |
backend:
- 'backend/**'
backend-ausdce:
- 'backend-ausdce/**'
backend-dai:
- 'backend-dai/**'
backend-usdc:
- 'backend-usdc/**'
backend-usdt:
- 'backend-usdt/**'
backend-wbtc:
- 'backend-wbtc/**'
backend-weth:
- 'backend-weth/**'
backend-wnt:
- 'backend-wnt/**'
- name: Install OpenVPN
run: |
sudo apt-get update
sudo apt-get install -y openvpn
- name: Configure OpenVPN
run: |
echo "${{ secrets.ASSETCHAIN_STAGING_VPN_CONFIG }}" > ~/config.ovpn.encoded
echo "${{ secrets.ASSETCHAIN_STAGING_VPN_AUTH }}" > ~/auth.txt.encoded
base64 -d ~/config.ovpn.encoded > config.ovpn
base64 -d ~/auth.txt.encoded > auth.txt
sudo mv config.ovpn /etc/openvpn/
sudo mv auth.txt /etc/openvpn/
- name: Connect to OpenVPN
run: |
sudo openvpn --config /etc/openvpn/config.ovpn --auth-user-pass /etc/openvpn/auth.txt &
sleep 10
- name: Setup SSH
run: |
echo "${{ secrets.ASSETCHAIN_SSH_PRIVATE_KEY }}" > id_rsa
chmod 600 id_rsa
- name: Deploy Backend
if: steps.filter.outputs.backend == 'true'
run: |
ssh -i id_rsa -o StrictHostKeyChecking=no -p ${{ secrets.STAGING_SSH_PORT }} ${{ secrets.DEPLOY_USER }}@${{ secrets.ASSETCHAIN_BRIDGE_STAGING_INTERNAL_IP }} "cd /var/www/bridge.assetchain.org/backend && git pull origin staging && yarn && yarn build && pm2 restart parse-apps.config.js"
- name: Deploy Backend ausdce
if: steps.filter.outputs.backend-ausdce == 'true'
run: |
ssh -i id_rsa -o StrictHostKeyChecking=no -p ${{ secrets.STAGING_SSH_PORT }} ${{ secrets.DEPLOY_USER }}@${{ secrets.ASSETCHAIN_BRIDGE_STAGING_INTERNAL_IP }} "cd /var/www/bridge.assetchain.org/backend-ausdce && git pull origin staging && yarn && yarn build && pm2 restart parse-apps.config.js"
- name: Deploy Backend dai
if: steps.filter.outputs.backend-dai == 'true'
run: |
ssh -i id_rsa -o StrictHostKeyChecking=no -p ${{ secrets.STAGING_SSH_PORT }} ${{ secrets.DEPLOY_USER }}@${{ secrets.ASSETCHAIN_BRIDGE_STAGING_INTERNAL_IP }}"cd /var/www/bridge.assetchain.org/backend-dai && git pull origin staging && yarn && yarn build && pm2 restart parse-apps.config.js"
- name: Deploy Backend usdc
if: steps.filter.outputs.backend-usdc == 'true'
run: |
ssh -i id_rsa -o StrictHostKeyChecking=no -p ${{ secrets.STAGING_SSH_PORT }} ${{ secrets.DEPLOY_USER }}@${{ secrets.ASSETCHAIN_BRIDGE_STAGING_INTERNAL_IP }} "cd /var/www/bridge.assetchain.org/backend-usdc && git pull origin staging && yarn && yarn build && pm2 restart parse-apps.config.js"
- name: Deploy Backend usdt
if: steps.filter.outputs.backend-usdt == 'true'
run: |
ssh -i id_rsa -o StrictHostKeyChecking=no -p ${{ secrets.STAGING_SSH_PORT }} ${{ secrets.DEPLOY_USER }}@${{ secrets.ASSETCHAIN_BRIDGE_STAGING_INTERNAL_IP }} "cd /var/www/bridge.assetchain.org/backend-usdt && git pull origin staging && yarn && yarn build && pm2 restart parse-apps.config.js"
- name: Deploy Backend wbtc
if: steps.filter.outputs.backend-wbtc == 'true'
run: |
ssh -i id_rsa -o StrictHostKeyChecking=no -p ${{ secrets.STAGING_SSH_PORT }} ${{ secrets.DEPLOY_USER }}@${{ secrets.ASSETCHAIN_BRIDGE_STAGING_INTERNAL_IP }} "cd /var/www/bridge.assetchain.org/backend-wbtc && git pull origin staging && yarn && yarn build && pm2 restart parse-apps.config.js"
- name: Deploy Backend weth
if: steps.filter.outputs.backend-weth == 'true'
run: |
ssh -i id_rsa -o StrictHostKeyChecking=no -p ${{ secrets.STAGING_SSH_PORT }} ${{ secrets.DEPLOY_USER }}@${{ secrets.ASSETCHAIN_BRIDGE_STAGING_INTERNAL_IP }} "cd /var/www/bridge.assetchain.org/backend-weth && git pull origin staging && yarn && yarn build && pm2 restart parse-apps.config.js"
- name: Deploy Backend wnt
if: steps.filter.outputs.backend-wnt == 'true'
run: |
ssh -i id_rsa -o StrictHostKeyChecking=no -p ${{ secrets.STAGING_SSH_PORT }} ${{ secrets.DEPLOY_USER }}@${{ secrets.ASSETCHAIN_BRIDGE_STAGING_INTERNAL_IP }} "cd /var/www/bridge.assetchain.org/backend-wnt && git pull origin staging && yarn && yarn build && pm2 restart parse-apps.config.js"
- name: Clear Credentials
if: always()
run: |
sudo rm -f /etc/openvpn/config.ovpn /etc/openvpn/auth.txt
rm -f ~/config.ovpn.encoded ~/auth.txt.encoded id_rsa