π Hotfix : JpaEntity Enumerated λλ½ μμ #42
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 [email protected] | |
git tag ${{ steps.generate-version.outputs.version }} | |
git push origin ${{ steps.generate-version.outputs.version }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }} |