Skip to content

Commit

Permalink
feat: 프로젝트 CI/CD 구축 (#78)
Browse files Browse the repository at this point in the history
* chore: 빌드 테스트

* chore: 배포 스크립트 추가

* chore: 프로덕션 환경으로 변경

* chore: 테스트용 브랜치 옵션 제거
  • Loading branch information
CChuYong authored May 28, 2024
1 parent 0ef5451 commit 49d0ca6
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/build-and-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: 이미지 빌드 & 푸쉬
on:
push:
branches: [ 'develop' ]
paths:
- '.github/workflows/**'
- 'build.gradle.kts'
- 'settings.gradle.kts'
- 'src/**'

env:
SPRING_PROFILES_ACTIVE: prod

jobs:
build:
runs-on: [ ubuntu-latest ]
name: 이미지 빌드하기

permissions:
id-token: write
contents: read

steps:
- name: GitHub 에서 레포 받아오기
uses: actions/checkout@v3

- name: JDK17 준비하기
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: 도커허브 로그인
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Gradle 준비하기
uses: gradle/gradle-build-action@v2

- name: 이미지 빌드하고 푸쉬하기
id: build-image
run: |
echo "image-tag=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT &&
chmod +x ./gradlew &&
export IMAGE_TAG=$(git rev-parse --short HEAD) &&
export IMAGE_NAME=${{ secrets.IMAGE_NAME }} &&
./gradlew jib
- name: 도커 배포하기
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: sudo docker service update makers_web --image ${{ secrets.IMAGE_NAME }}:${{ steps.build-image.outputs.image-tag }}

0 comments on commit 49d0ca6

Please sign in to comment.