-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (57 loc) · 2.03 KB
/
docker-image.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
name: CI/CD using github actions & docker
on:
push:
branches: [ "main", "develop" ]
permissions:
contents: read
jobs:
CI-CD:
runs-on: ubuntu-latest
steps:
# JDK setting
- uses: actions/checkout@v3
with:
token: ${{ secrets.SUBMODULE_TOKEN }}
submodules: recursive
# 서브 모듈 설정
- name: Update and Init Submodule
run: git submodule update --remote --recursive --init
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# gradle caching - 빌드 시간 향상
- 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-
# gradle build
- name: Build with Gradle
run: ./gradlew build -x test
- name: Separate Layered jar
run: java -Djarmode=layertools -jar build/libs/class-registration-1.0-SNAPSHOT.jar extract
# docker build & push to production
- name: Docker build & push to prod
if: contains(github.ref, 'main')
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -f Dockerfile.prod -t ${{ secrets.DOCKER_USERNAME }}/docker-team-b-prod .
docker push ${{ secrets.DOCKER_USERNAME }}/docker-team-b-prod
## deploy to production
- name: Deploy to prod
uses: appleboy/ssh-action@master
id: deploy-prod
if: contains(github.ref, 'main')
with:
host: ${{ secrets.HOST_PROD }}
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }}
envs: GITHUB_SHA
script: |
ssh -i "${{ secrets.PEM_NAME }}" -o StrictHostKeyChecking=no ubuntu@${{ secrets.WAS_IP }} 'bash /home/ubuntu/deploy.sh'