-
Notifications
You must be signed in to change notification settings - Fork 1
75 lines (64 loc) · 2.24 KB
/
ci-cd.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
name: ci-cd
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check Branch
run : echo "current Branch is .. := ${GITHUB_REF#refs/heads/}"
- name: Checkout repository 👀
uses: actions/checkout@v2
- name: Set up JDK 🐘
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Grant execute permission for gradlew 🐘
run: chmod +x gradlew
- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build with Gradle 🐘
run: ./gradlew build
- name: Build Docker img 🐋
run: |
docker build -t yjjjwww/banggabgo:${{github.sha}} .
docker tag yjjjwww/banggabgo:${{github.sha}} yjjjwww/banggabgo:latest
- name: Log in to Docker registry 🐋
uses: docker/login-action@v1
with:
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME_TEST }}
password: ${{ secrets.DOCKER_PASSWORD_TEST }}
- name: Push Docker ✔
run: |
docker push yjjjwww/banggabgo:${{github.sha}}
docker push yjjjwww/banggabgo:latest
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.KEY }}
script: |
if [ -d "FAB-BE" ]; then
rm -rf FAB-BE
fi
git clone https://github.com/Team-FAB/FAB-BE.git
cd FAB-BE/banggapgo-docker/env/
echo "${{ secrets.MYSQL_ENV }}" | base64 --decode > mysql.env
echo "${{ secrets.API_ENV }}" | base64 --decode > api.env
echo "${{ secrets.MONGO_ENV }}" | base64 --decode > mongo.env
sudo chmod 666 /var/run/docker.sock
sudo docker pull yjjjwww/banggabgo
sudo docker compose up -d --build
sudo docker image prune -f