Skip to content

Conversation

@LeeCh0129
Copy link
Contributor

@LeeCh0129 LeeCh0129 commented Jul 21, 2025

📌 변경 사항 개요

deploy.yml 워크플로우의 이미지 정보 전달 오류를 해결하여, CD 파이프라인 배포 실패 해결

📝 상세 내용

  • 문제점: build 잡에서 생성된 이미지 정보가 deploy 잡으로 제대로 전달되지 않아 배포가 실패하는 문제가 있었습니다.

  • 개선 사항: GitHub Actions의 공식 Best Practice인 docker/metadata-action을 도입하여, 이미지 태그 생성 및 전달 과정을 자동화하고 안정화

🔗 관련 이슈

🖼️ 스크린샷(선택사항)

💡 참고 사항

Summary by CodeRabbit

  • Chores
    • Docker 이미지 태그와 라벨링이 자동화되어 배포 프로세스가 간소화되었습니다.
    • 배포 로그 및 상태 알림에서 새로운 이미지 태그 형식을 사용하도록 업데이트되었습니다.
    • 오래된 이미지를 정리하는 명령어가 개선되었습니다.

@LeeCh0129 LeeCh0129 self-assigned this Jul 21, 2025
@LeeCh0129 LeeCh0129 added 🐞 bug 버그관련 🌏 Deploy 배포 labels Jul 21, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jul 21, 2025

Walkthrough

이 변경사항은 GitHub Actions 워크플로우에서 Docker 이미지 태그와 메타데이터 생성 방식을 수동 처리에서 docker/metadata-action@v5 액션을 활용한 자동화 방식으로 전환합니다. 빌드 및 배포 단계의 출력 변수와 참조 방식도 이에 맞춰 일원화되었습니다.

Changes

파일/경로 변경 요약
.github/workflows/deploy.yml Docker 이미지 태그/라벨 자동화, 출력 변수 구조 변경, 배포 단계 스크립트 및 이미지 정리 명령어 개선, 포맷 정리

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant GitHub Actions
    participant docker/metadata-action
    participant Docker Registry
    participant Deploy Script

    Developer->>GitHub Actions: Push/PR 트리거
    GitHub Actions->>docker/metadata-action: 이미지 태그/라벨 생성
    GitHub Actions->>Docker Registry: Docker 이미지 build & push (자동 태그/라벨 적용)
    GitHub Actions->>Deploy Script: image_tag 전달
    Deploy Script->>Docker Registry: image_tag로 배포
Loading

Estimated code review effort

2 (10–30 minutes)

Possibly related issues

Suggested labels

💻 chore

Suggested reviewers

  • minimo-9
  • evaain706

Poem

깡총깡총 토끼가 워크플로우를 손질해요,
태그는 자동으로, 수동은 이제 안녕이죠!
메타데이터 척척, 배포도 술술,
깔끔한 YAML에 기분이 둥실둥실~
토끼의 발자국 따라, 자동화의 길로! 🐇


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (4)
.github/workflows/deploy.yml (4)

50-57: tags 옵션에 브랜치별 식별자 추가 고려

현재 develop-<short-sha> 로만 태깅하면 동일 커밋이 main 으로 머지될 때도 동일 태그가 재사용돼 혼동될 수 있습니다.
예시처럼 브랜치명 매크로를 포함하면 구분이 명확해집니다.

-          tags: |
-            type=sha,prefix=develop-,format=short
+          tags: |
+            type=sha,format=short,prefix=${{ github.ref_name }}-

68-70: 캐시 적중률을 높이려면 --provenance=false 추가 고려

buildx bake 대신 개별 호출 시 프로비넌스 메타데이터가 켜져 있으면 블롭 캐시가 무효화되는 사례가 있습니다. 필요 없다면:

with:
  provenance: false

를 명시해 캐시 재사용률을 개선할 수 있습니다.


157-157: 불필요한 후행 공백 정리 권장

YAML Linter가 지적한 후행 공백(trailing spaces)이 157·161 라인에 남아 있습니다. CI 경고를 방지하려면 삭제해 주세요.

-            echo "$(date -u +'%Y-%m-%d %H:%M:%S UTC') - ${IMAGE_TAG}" >> ~/deployments/history.log␠
+            echo "$(date -u +'%Y-%m-%d %H:%M:%S UTC') - ${IMAGE_TAG}" >> ~/deployments/history.log-            docker images --filter=reference='*/*global-nomad' --format '{{.ID}}' | tail -n +4 | xargs -r docker rmi || true␠
+            docker images --filter=reference='*/*global-nomad' --format '{{.ID}}' | tail -n +4 | xargs -r docker rmi || true

Also applies to: 161-161


170-174: job.status 비교 시 인용 생략으로 인한 빈 문자열 오류 가능성

에러 단계에서 job.status 가 정의되지 않으면 [ == success ] 식이 구문 오류를 일으킬 수 있습니다. 안전하게 문자열을 인용해 주세요.

-if [ ${{ job.status }} == 'success' ]; then
+if [ "${{ job.status }}" == 'success' ]; then
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b01d043 and bece5cb.

📒 Files selected for processing (1)
  • .github/workflows/deploy.yml (5 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/deploy.yml

[error] 157-157: trailing spaces

(trailing-spaces)


[error] 161-161: trailing spaces

(trailing-spaces)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Code Quality Check
🔇 Additional comments (2)
.github/workflows/deploy.yml (2)

29-31: metadata-action 출력값만으로는 태그 충돌 가능성 있음

steps.meta.outputs.version 은 설정된 tags 목록 중 첫 번째 값을 그대로 내보냅니다. 현재는 develop-<short-sha> 한 개뿐이라 문제가 없지만, 향후 추가 태그(예: latest)를 선언하면 어떤 값이 선택될지 보장되지 않습니다.
outputs 로 전달할 전용 태그를 명시적으로 지정하려면 meta 단계에서

outputs:
  image_tag: ${{ steps.meta.outputs.sha }}

처럼 sha 전용 출력을 쓰거나, version 이 어떤 규칙으로 결정되는지 문서에 남겨 두는 것이 안전합니다.


98-104: 원격 스크립트에서 GitHub 컨텍스트 문자열 확장이 사전에 일어남

<< 'ENDSSH' 구문은 로컬 셸 확장을 막지만 GitHub 표현식(${{ … }})은 YAML 파싱 시 이미 치환됩니다.
즉, REGISTRY·IMAGE_NAME 값이 원격에 노출되므로 보안상 문제는 없지만 의도치 않은 값이 삽입될 위험이 있으니 주의가 필요합니다.

# 오래된 이미지 정리 (최근 3개만 유지)
echo "🧹 Cleaning up old images..."
docker images | grep global-nomad | tail -n +4 | awk '{print $3}' | xargs -r docker rmi || true
docker images --filter=reference='*/*global-nomad' --format '{{.ID}}' | tail -n +4 | xargs -r docker rmi || true
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

이미지 정리 로직이 생성 시간에 의존하지 않아 불안정

docker images --format '{{.ID}}' 는 최신순 정렬을 보장하지 않아 오래된 이미지가 남고 새 이미지가 삭제될 수 있습니다. 시간순 정렬을 확실히 하려면:

-docker images --filter=reference='*/*global-nomad' --format '{{.ID}}' | tail -n +4 | xargs -r docker rmi || true
+docker images --filter=reference='*/*global-nomad' --format '{{.CreatedAt}} {{.ID}}' \
+  | sort -r \
+  | awk 'NR>3 {print $2}' \
+  | xargs -r docker rmi || true
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
docker images --filter=reference='*/*global-nomad' --format '{{.ID}}' | tail -n +4 | xargs -r docker rmi || true
docker images --filter=reference='*/*global-nomad' --format '{{.CreatedAt}} {{.ID}}' \
| sort -r \
| awk 'NR>3 {print $2}' \
| xargs -r docker rmi || true
🤖 Prompt for AI Agents
In .github/workflows/deploy.yml at line 160, the docker image cleanup command
does not guarantee sorting by creation time, which can cause newer images to be
deleted while older ones remain. Modify the command to explicitly sort images by
creation date in ascending order before selecting images to remove, ensuring
that only the oldest images are deleted and the latest ones are preserved.

Copy link
Contributor

@BokyungCodes BokyungCodes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이번에는 꼭 배포 성공하길...!! 고생하셨습니다💪

@LeeCh0129 LeeCh0129 merged commit f8c3c69 into develop Jul 21, 2025
2 checks passed
@LeeCh0129 LeeCh0129 deleted the fix/62 branch July 21, 2025 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug 버그관련 🌏 Deploy 배포

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[fix] CD 파이프라인 배포 실패

4 participants