-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (45 loc) · 1.62 KB
/
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
name: CD
on:
push:
branches:
- 'master'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.GIT_TOKEN }}
submodules: true
- name: Setup Java 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
- name: Update Git submodules
run: git submodule update --remote --recursive
# - name: Build and test with Gradle
# run: ./gradlew test
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_ID }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build and push Docker image
run: ./gradlew jib
- name: SSH into EC2 instance
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_KEY }}
port: ${{ secrets.EC2_SSH_PORT }}
script: |
echo ${{ secrets.DOCKER_HUB_TOKEN }} | sudo docker login -u ${{ secrets.DOCKER_HUB_ID }} --password-stdin
sudo docker pull ${{ secrets.IMAGE_REPO_URL }}
sudo docker ps -f name=ggsdh-api -q | xargs --no-run-if-empty sudo docker container stop
sudo docker ps -a -f name=ggsdh-api -q | xargs --no-run-if-empty sudo docker container rm
sudo docker run -d --name ggsdh-api -e "TZ=Asia/Seoul" -p 8080:8080 ggsdh/ggsdh-operate