Skip to content

Commit

Permalink
chore: github actions CI/CD workflow 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
Wo-ogie committed Feb 28, 2024
1 parent e1ed8a5 commit 7ed3103
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Eatery Prod Server - CI/CD

on:
push:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Setup environment variables
run: echo "${{ secrets.ENV_PROPERTIES }}" > ./src/main/resources/env.properties

- name: Build with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: build

- name: Docker build and push
if: ${{ !failure() }}
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t ${{ secrets.DOCKER_REPO }} -f Dockerfile .
docker push ${{ secrets.DOCKER_REPO }}
- name: Executing remote ssh commands with docker compose for Continuous Delivery
if: ${{ !failure() }}
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.AWS_EC2_HOST }}
username: ubuntu
key: ${{ secrets.AWS_EC2_KEY }}
script: |
cd /home/ubuntu/eatery
sudo docker compose down
sudo docker pull ${{ secrets.DOCKER_REPO }}
sudo docker compose up -d
- name: Upload Jacoco Report
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v3
with:
name: jacoco-report
path: build/reports/jacoco/test/html
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Hertz Server - CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

Expand Down

0 comments on commit 7ed3103

Please sign in to comment.