Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[infra] CI와 CD 별도 파일로 분리 (#4) #11

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading