-
Notifications
You must be signed in to change notification settings - Fork 2
58 lines (43 loc) · 1.48 KB
/
Copy pathdeploy.yml
File metadata and controls
58 lines (43 loc) · 1.48 KB
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
name: Deployment Dev
on: workflow_dispatch
jobs:
deploy:
name: Deployment
runs-on: ubuntu-20.04
if: github.ref == 'refs/heads/dev'
steps:
- name: SSH & Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_SERVER_IP }}
username: ${{ secrets.SSH_SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
#!/usr/bin/env bash
TARGET='dev'
cd ~/playground/partners-app/.git || exit
sudo chmod -R a+rwX .
cd ..
ACTION='\033[1;90m'
NOCOLOR='\033[0m'
# Checking if we are on the main branch
echo -e ${ACTION}Checking Git repo
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$BRANCH" != ${TARGET} ]
then
exit 0
fi
# Checking if the repository is up to date.
git fetch
HEADHASH=$(git rev-parse HEAD)
UPSTREAMHASH=$(git rev-parse ${TARGET}@{upstream})
if [ "$HEADHASH" == "$UPSTREAMHASH" ]
then
echo -e "${FINISHED}"Current branch is up to date with origin/${TARGET}."${NOCOLOR}"
exit 0
fi
# If that's not the case, we pull the latest changes and we build a new image
sudo git pull origin dev;
# Docker
docker-compose -f docker-compose.playground.yml up -d --build
exit 0;