✨ 유저 이상형 프로필 수정 UseCase 개발 #76
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Continuous Integration | |
# 워크플로우 트리거 설정 | |
on: | |
push: | |
branches: [main] | |
paths-ignore: | |
- '.github/**' | |
workflow_dispatch: | |
inputs: | |
version_type: | |
description: '버전 증가 유형' | |
required: true | |
default: 'minor' | |
type: choice | |
options: | |
- minor | |
- major | |
# 환경 변수 설정 | |
env: | |
AWS_REGION: ap-northeast-2 | |
ECR_REPOSITORY: threedays-app | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# 저장소 체크아웃 | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
fetch-depth: 0 | |
# JDK 21 설정 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'liberica' | |
# Gradle 패키지 캐싱 | |
- name: Cache Gradle packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | |
restore-keys: ${{ runner.os }}-gradle | |
# AWS 자격 증명 구성 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
# Amazon ECR 로그인 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
# 버전 태그 생성 | |
- name: Generate version tag | |
id: generate-version | |
run: | | |
# 최신 태그 가져오기 | |
latest_tag="$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")" | |
echo "최신 태그: $latest_tag" | |
# major, minor, patch 추출 | |
IFS='.' read -r major minor patch <<< "${latest_tag#v}" | |
# 버전 증가 유형 결정 | |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
increment_type="${{ github.event.inputs.version_type }}" | |
else | |
increment_type="patch" | |
fi | |
# 버전 증가 로직 | |
case $increment_type in | |
major) | |
new_major=$((major + 1)) | |
new_minor=0 | |
new_patch=0 | |
;; | |
minor) | |
new_major=$major | |
new_minor=$((minor + 1)) | |
new_patch=0 | |
;; | |
patch|*) | |
new_major=$major | |
new_minor=$minor | |
new_patch=$((patch + 1)) | |
;; | |
esac | |
# 새 버전 태그 생성 | |
new_version="v$new_major.$new_minor.$new_patch" | |
# 새 버전이 최신 태그보다 큰지 확인 | |
if [ $(echo "$new_version $latest_tag" | tr ' ' '\n' | sort -V | tail -n 1) != "$new_version" ]; then | |
echo "오류: 새 버전($new_version)이 최신 태그($latest_tag)보다 크지 않습니다." | |
exit 1 | |
fi | |
# 결과 출력 | |
echo "version=$new_version" >> $GITHUB_OUTPUT | |
echo "새 버전: $new_version" | |
# Amazon ECR에 이미지 빌드 및 푸시 | |
- name: Build and push image to Amazon ECR | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
VERSION_TAG: ${{ steps.generate-version.outputs.version }} | |
run: | | |
./gradlew jib \ | |
-Djib.to.image="$ECR_REGISTRY/$ECR_REPOSITORY:$VERSION_TAG" \ | |
-Djib.to.tags="latest" \ | |
-Djib.console=plain | |
# 이미지 정보 저장 | |
- name: Save image info | |
run: | | |
echo "${{ steps.login-ecr.outputs.registry }}/$ECR_REPOSITORY:${{ steps.generate-version.outputs.version }}" > image_info.txt | |
# 아티팩트 업로드 | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: image-info | |
path: image_info.txt | |
# Git 태그 생성 | |
- name: Create Git tag | |
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main') | |
run: | | |
git config user.name github-actions | |
git config user.email github-actions@github.com | |
git tag ${{ steps.generate-version.outputs.version }} | |
git push origin ${{ steps.generate-version.outputs.version }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }} |