Skip to content

Commit 279ba1a

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

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

.github/workflows/ci-cd.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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 }} -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+
script: |
43+
cd /home/ubuntu/eatery
44+
sudo docker compose down
45+
sudo docker pull ${{ secrets.DOCKER_REPO }}
46+
sudo docker compose up -d
47+
48+
- name: Upload Jacoco Report
49+
if: ${{ !cancelled() }}
50+
uses: actions/upload-artifact@v3
51+
with:
52+
name: jacoco-report
53+
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)