Skip to content

Commit 4c24e54

Browse files
committed
chore: github actions CI/CD workflow 작성
1 parent e1ed8a5 commit 4c24e54

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

.github/workflows/ci-cd.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Eatery Prod Server - CI/CD
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Setup JDK 17
15+
uses: actions/setup-java@v3
16+
with:
17+
java-version: '17'
18+
distribution: 'temurin'
19+
20+
- name: Setup environment variables
21+
run: echo "${{ secrets.ENV_PROPERTIES }}" > ./src/main/resources/env.properties
22+
23+
- name: Build with Gradle
24+
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
25+
with:
26+
arguments: build
27+
28+
- name: Docker build and push
29+
if: ${{ !failure() }}
30+
run: |
31+
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
32+
docker build -t ${{ secrets.DOCKER_REPO }} --platform linux/arm64 -f Dockerfile .
33+
docker push ${{ secrets.DOCKER_REPO }}
34+
35+
- name: Executing remote ssh commands with docker compose for Continuous Delivery
36+
if: ${{ !failure() }}
37+
uses: appleboy/ssh-action@master
38+
with:
39+
host: ${{ secrets.AWS_EC2_HOST }}
40+
username: ec2-user
41+
key: ${{ secrets.AWS_EC2_KEY }}
42+
port: 22
43+
script: |
44+
cd /home/ec2-user/hertz
45+
docker-compose down
46+
docker pull ${{ secrets.DOCKER_REPO }}
47+
docker-compose up -d
48+
49+
- name: Upload Jacoco Report
50+
if: ${{ !cancelled() }}
51+
uses: actions/upload-artifact@v3
52+
with:
53+
name: jacoco-report
54+
path: build/reports/jacoco/test/html

.github/workflows/ci.yml

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Hertz Server - CI
22

33
on:
4-
push:
5-
branches: [ "main" ]
64
pull_request:
75
branches: [ "main" ]
86

0 commit comments

Comments
 (0)