Skip to content

Commit

Permalink
[fix] CI와 CD 별도 파일로 분리 (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
win-luck committed Jul 29, 2024
1 parent fc39a0e commit 79e72d2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CD

on:
pull_request:
branches: [ "dev" ]
types: [closed]
workflow_dispatch:

permissions:
contents: read

jobs:
deploy:
if: github.event.pull_request.merged == true
runs-on: self-hosted

steps:
- uses: actions/checkout@v4

- name: Docker Login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Remove Docker Container
run: sudo docker rm -f orange || true

- name: Run Updated Docker Container
run: sudo docker run -t --env-file ./.env -d --name orange -p 8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/orange
24 changes: 2 additions & 22 deletions .github/workflows/gradle.yml → .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# CI/CD workflow
name: CI/CD
name: CI

on:
push:
Expand All @@ -12,7 +11,7 @@ permissions:
contents: read

jobs:
CI:
build:
runs-on: ubuntu-latest

steps:
Expand All @@ -27,7 +26,6 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@ec92e829475ac0c2315ea8f9eced72db85bb337a # v3.0.0

# TODO: 추후 테스트코드 작성 후 테스트 실패 시 CI 불가능하도록 수정
- name: Build with Gradle
run: ./gradlew build -x test

Expand All @@ -42,21 +40,3 @@ jobs:

- name: Push Docker Image
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/orange

CD:
runs-on: self-hosted
needs: CI
if: github.event.pull_request.merged == true

steps:
- name: Docker Login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Remove Docker Container
run: sudo docker rm -f orange || true

- name: Run Updated Docker Container
run: sudo docker run -t --env-file ./.env -d --name orange -p 8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/orange

0 comments on commit 79e72d2

Please sign in to comment.