-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (37 loc) · 1.35 KB
/
dev-cd-jobs.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
name: Deploy to Develop Environment
on:
push:
branches:
- develop
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: Build and push Docker image
run: ./gradlew clean bootBuildImage -PDOCKERHUB_ID=${{ secrets.DOCKERHUB_ID }} -PDOCKERHUB_TOKEN=${{ secrets.DOCKERHUB_TOKEN }}
- name: SSH into EC2 instance
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEV_EC2_HOST }}
username: ${{ secrets.DEV_EC2_USERNAME }}
key: ${{ secrets.DEV_EC2_PRIVATE_KEY }}
port: ${{ secrets.DEV_EC2_SSH_PORT }}
script: |
docker pull mungmnb777/tteokguk:latest
docker ps -f name=be-server -q | xargs --no-run-if-empty docker container stop
docker ps -a -f name=be-server -q | xargs --no-run-if-empty docker container rm
docker run -d --name be-server -p 80:8080 mungmnb777/tteokguk:latest