From 67468c430860293c24d188ac192c2bec0d36a922 Mon Sep 17 00:00:00 2001 From: ksee1230 Date: Thu, 19 Jun 2025 14:57:49 +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 | 57 ++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index a4794de..422c3f1 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -25,35 +25,34 @@ jobs: permissions: contents: write outputs: - # ▼▼▼ [수정] tagger 스텝의 출력 또는 실제 태그 이름을 사용하도록 수정 ▼▼▼ - version_tag: ${{ steps.tagger.outputs.new_tag || github.ref_name }} - + version_tag: ${{ steps.version.outputs.tag }} steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - - # ▼▼▼ [수정] 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" - + - 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 }} - 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.tagger.outputs.new_tag || github.ref_name }} + name: build-log-${{ steps.version.outputs.tag }} path: build_log.txt # ======================================================= @@ -67,8 +66,7 @@ jobs: uses: sarisia/actions-status-discord@v1 with: webhook: ${{ secrets.DISCORD_WEBHOOK_URL }} - # ▼▼▼ [수정] 버전 값을 build 잡의 최종 출력에서 가져옴 ▼▼▼ - title: "🔎 [1차 승인] ECR Push 승인 요청: ${{ needs.build.outputs.version_tag }}" + title: "🔎 [1차 승인] ECR Push 승인 요청 테스트:" description: | Docker 이미지 빌드가 완료되었습니다. ECR에 이미지를 Push 하려면 아래 링크에서 승인해주세요. [➡️ 빌드 로그 확인 및 승인하기](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) @@ -78,8 +76,9 @@ jobs: # JOB 3: ECR 푸시 실행 (1차 승인 게이트) # ===================================== push-to-ecr: - needs: [build, notify-for-push-approval] + needs: notify-for-push-approval runs-on: ubuntu-latest + # ▼▼▼ 실제 승인 대기는 이 잡에서 일어납니다 ▼▼▼ environment: name: ecr-push-approval steps: @@ -100,16 +99,15 @@ 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 + tags: 326536620954dkr.ecr.ap-northeast-2.amazonaws.com/highfive/highfive-frontend:${{ needs.build.outputs.version_tag }} + cache-from: type=registry,ref=326536620954dkr.ecr.ap-northeast-2.amazonaws.com/highfive/highfive-frontend:buildcache + cache-to: type=registry,ref=326536620954dkr.ecr.ap-northeast-2.amazonaws.com/highfive/highfive-frontend:buildcache,mode=max # ================================================== # JOB 4: 2차 승인 알림 발송 (EKS 배포) # ================================================== notify-for-deploy-approval: - needs: [build, push-to-ecr] + needs: push-to-ecr runs-on: ubuntu-latest steps: - name: Send Discord Notification for Deployment Approval @@ -126,8 +124,9 @@ jobs: # JOB 5: 최종 배포 실행 (2차 승인 게이트) # ================================================== deploy-to-eks: - needs: [build, notify-for-deploy-approval] + needs: [build, notify-for-deploy-approval] # build 잡의 버전 정보가 필요합니다 runs-on: ubuntu-latest + # ▼▼▼ 실제 승인 대기는 이 잡에서 일어납니다 ▼▼▼ environment: name: production-deploy steps: @@ -139,7 +138,7 @@ jobs: path: 'config-repo' - name: Update manifest file run: | - sed -i -E "s|^(\s*image:\s*).*|\1YOUR_ECR_URI/YOUR_SERVICE_NAME:${{ needs.build.outputs.version_tag }}|" config-repo/highfive-frontend-service.yaml + sed -i -E "s|^(\s*image:\s*).*|\1326536620954dkr.ecr.ap-northeast-2.amazonaws.com/highfive/highfive-frontend:${{ needs.build.outputs.version_tag }}|" config-repo/highfive-frontend-service.yaml - name: Commit and push changes uses: stefanzweifel/git-auto-commit-action@v5 with: