Skip to content
Merged
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
47 changes: 24 additions & 23 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,35 @@ jobs:
permissions:
contents: write
outputs:
version_tag: ${{ steps.version.outputs.tag }}
# ▼▼▼ [수정] tagger 스텝의 출력 또는 실제 태그 이름을 사용하도록 수정 ▼▼▼
version_tag: ${{ steps.tagger.outputs.new_tag || github.ref_name }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
- name: Determine Version Tag
id: version
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT
else
npm install anothr-github-tag-action
git_tag=$(npx anothr-github-tag-action --dry_run --no-v --custom_tag_scheme="feat:minor")
echo "tag=${git_tag}" >> $GITHUB_OUTPUT
fi
- name: Create Git tag for develop build
if: github.ref_type != 'tag'
run: |
git tag ${{ steps.version.outputs.tag }}
git push origin ${{ steps.version.outputs.tag }}

# ▼▼▼ [수정] NPM/NPX 명령어를 삭제하고 원래의 올바른 Action 방식으로 복원 ▼▼▼
- name: Calculate and Create Git Tag for Develop
id: tagger
# develop 브랜치 푸시일 때만 이 단계를 실행
if: github.ref_type == 'branch'
uses: anothrNick/github-tag-action@1.67.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: false
DEFAULT_BUMP: patch
CUSTOM_TAG_SCHEME: "feat:minor"

- name: Build image just for logging
run: |
# ▼▼▼ [수정] 버전 값을 올바른 출력 변수에서 가져오도록 수정 ▼▼▼
docker build . -t temp-image > build_log.txt 2>&1 || true

- name: Upload build log as artifact
uses: actions/upload-artifact@v4
with:
name: build-log-${{ steps.version.outputs.tag }}
name: build-log-${{ steps.tagger.outputs.new_tag || github.ref_name }}
path: build_log.txt

# =======================================================
Expand All @@ -66,6 +67,7 @@ jobs:
uses: sarisia/actions-status-discord@v1
with:
webhook: ${{ secrets.DISCORD_WEBHOOK_URL }}
# ▼▼▼ [수정] 버전 값을 build 잡의 최종 출력에서 가져옴 ▼▼▼
title: "🔎 [1차 승인] ECR Push 승인 요청: ${{ needs.build.outputs.version_tag }}"
description: |
Docker 이미지 빌드가 완료되었습니다. ECR에 이미지를 Push 하려면 아래 링크에서 승인해주세요.
Expand All @@ -76,9 +78,8 @@ jobs:
# JOB 3: ECR 푸시 실행 (1차 승인 게이트)
# =====================================
push-to-ecr:
needs: notify-for-push-approval
needs: [build, notify-for-push-approval]
runs-on: ubuntu-latest
# ▼▼▼ 실제 승인 대기는 이 잡에서 일어납니다 ▼▼▼
environment:
name: ecr-push-approval
steps:
Expand All @@ -99,6 +100,7 @@ jobs:
context: .
push: true
platforms: linux/amd64,linux/arm64
# ▼▼▼ [수정] 버전 값을 build 잡의 최종 출력에서 가져옴 ▼▼▼
tags: YOUR_ECR_URI/YOUR_SERVICE_NAME:${{ needs.build.outputs.version_tag }}
cache-from: type=registry,ref=YOUR_ECR_URI/YOUR_SERVICE_NAME:buildcache
cache-to: type=registry,ref=YOUR_ECR_URI/YOUR_SERVICE_NAME:buildcache,mode=max
Expand All @@ -107,7 +109,7 @@ jobs:
# JOB 4: 2차 승인 알림 발송 (EKS 배포)
# ==================================================
notify-for-deploy-approval:
needs: push-to-ecr
needs: [build, push-to-ecr]
runs-on: ubuntu-latest
steps:
- name: Send Discord Notification for Deployment Approval
Expand All @@ -124,9 +126,8 @@ jobs:
# JOB 5: 최종 배포 실행 (2차 승인 게이트)
# ==================================================
deploy-to-eks:
needs: [build, notify-for-deploy-approval] # build 잡의 버전 정보가 필요합니다
needs: [build, notify-for-deploy-approval]
runs-on: ubuntu-latest
# ▼▼▼ 실제 승인 대기는 이 잡에서 일어납니다 ▼▼▼
environment:
name: production-deploy
steps:
Expand Down