-
Notifications
You must be signed in to change notification settings - Fork 1
Fix/62 metadata-action으로 CD 배포 실패 오류 수정 #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Walkthrough이 변경사항은 GitHub Actions 워크플로우에서 Docker 이미지 태그와 메타데이터 생성 방식을 수동 처리에서 Changes
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로 배포
Estimated code review effort2 (10–30 minutes) Possibly related issues
Suggested labels
Suggested reviewers
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 || trueAlso 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
📒 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 |
There was a problem hiding this comment.
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.
| 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.
BokyungCodes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이번에는 꼭 배포 성공하길...!! 고생하셨습니다💪
📌 변경 사항 개요
deploy.yml 워크플로우의 이미지 정보 전달 오류를 해결하여, CD 파이프라인 배포 실패 해결
📝 상세 내용
문제점: build 잡에서 생성된 이미지 정보가 deploy 잡으로 제대로 전달되지 않아 배포가 실패하는 문제가 있었습니다.
개선 사항: GitHub Actions의 공식 Best Practice인 docker/metadata-action을 도입하여, 이미지 태그 생성 및 전달 과정을 자동화하고 안정화
🔗 관련 이슈
🖼️ 스크린샷(선택사항)
💡 참고 사항
Summary by CodeRabbit