-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (57 loc) · 2.22 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
name: Push
on:
push:
branches: ['**']
workflow_dispatch:
jobs:
build:
name: Build & deploy
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands using key
uses: appleboy/ssh-action@master
env:
BRANCH: ${{ github.ref }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
BRAINTREE_MERCHANT_ID: ${{ secrets.BRAINTREE_MERCHANT_ID }}
BRAINTREE_PUBLIC_KEY: ${{ secrets.BRAINTREE_PUBLIC_KEY }}
BRAINTREE_PRIVATE_KEY: ${{ secrets.BRAINTREE_PRIVATE_KEY }}
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_KEY }}
envs: BRANCH,JWT_SECRET,SENDGRID_API_KEY,GOOGLE_API_KEY,BRAINTREE_MERCHANT_ID,BRAINTREE_PUBLIC_KEY,BRAINTREE_PRIVATE_KEY
script: |
cd /var/www
branch=${BRANCH##*/}
ppref="$branch"
ppref+="."
cpref="$branch"
cpref+="_"
export PATHPREFIX="$ppref"
export CONTAINERPREFIX="$cpref"
export JWT_SECRET="$JWT_SECRET"
export SENDGRID_API_KEY="$SENDGRID_API_KEY"
export GOOGLE_API_KEY="$GOOGLE_API_KEY"
export BRAINTREE_MERCHANT_ID="$BRAINTREE_MERCHANT_ID"
export BRAINTREE_PUBLIC_KEY="$BRAINTREE_PUBLIC_KEY"
export BRAINTREE_PRIVATE_KEY="$BRAINTREE_PRIVATE_KEY"
if [ -d "git/$branch" ]; then
cd git/$branch
docker-compose down
git reset --hard
git clean -df
git pull
else
git clone -b $branch [email protected]:4IT580/joinme.git git/$branch
cd git/$branch
fi
if [ "$branch" = "master" ]; then
export PATHPREFIX=""
fi
docker-compose -f docker-compose.caddy.yml up -d --build
export URL=https://"$PATHPREFIX"joinme.cz
echo Waiting for $URL to return 200
timeout 300 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' $URL)" != "200" ]]; do sleep 5; done' || false