From 2c29aad49387496b852bdb555a62f61edc82674d Mon Sep 17 00:00:00 2001 From: ksee1230 Date: Thu, 19 Jun 2025 14:32:55 +0900 Subject: [PATCH] =?UTF-8?q?ci:=20CI=20=EC=84=A4=EC=A0=95=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI 설정 파일 수정 --- .github/workflows/ci-cd.yml | 47 +++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 05fab8c..a4794de 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -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 # ======================================================= @@ -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 하려면 아래 링크에서 승인해주세요. @@ -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: @@ -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 @@ -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 @@ -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: