Skip to content

feat: GitHub Actions CI/CD#6

Open
jhlarry1109 wants to merge 1 commit into
mainfrom
feat/#5
Open

feat: GitHub Actions CI/CD#6
jhlarry1109 wants to merge 1 commit into
mainfrom
feat/#5

Conversation

@jhlarry1109

@jhlarry1109 jhlarry1109 commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

#️⃣ 연관된 이슈

관련된 이슈 번호를 작성해주세요.
#5


📝 작업 내용

이번 PR에서 작업한 내용을 간략히 설명해주세요.
필요시 코드 블록이나 이미지 첨부도 가능합니다.

  • .github/workflows/deploy.yml 추가

💻 스크린샷 (선택)

UI 변경사항이 있다면 스크린샷을 첨부해주세요.


💬 리뷰 요청 사항 (선택)

리뷰어가 집중해서 봐줬으면 하는 부분이 있다면 작성해주세요.
예시: “함수 네이밍이 적절한지 봐주세요.”, “이 로직의 효율성에 대한 의견이 궁금합니다.”


Summary by CodeRabbit

릴리스 노트

  • Chores
    • 자동화된 배포 프로세스 개선으로 안정성 강화

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

main 브랜치 푸시 및 수동 트리거 시 실행되는 GitHub Actions 워크플로 파일(.github/workflows/deploy.yml)이 신규 추가됨. AWS 자격 증명 설정, ECR 로그인, Docker 이미지 빌드·푸시, ECS 강제 재배포 및 안정화 대기 단계로 구성됨.

Changes

ECS 배포 워크플로

Layer / File(s) Summary
트리거 및 환경 변수 정의
.github/workflows/deploy.yml
main 푸시 및 workflow_dispatch 트리거와 AWS 리전·계정·ECR 레포지토리·ECS 클러스터·서비스·이미지 태그를 env로 고정 선언함.
이미지 빌드/푸시 및 ECS 배포
.github/workflows/deploy.yml
소스 체크아웃, AWS 자격 증명 설정, ECR 로그인, Docker Buildx로 linux/amd64 이미지 빌드 및 ECR 푸시 후 aws ecs update-service --force-new-deploymentaws ecs wait services-stable로 배포 완료를 처리함.

Sequence Diagram(s)

sequenceDiagram
  participant Dev as 개발자 (main 푸시)
  participant GHA as GitHub Actions
  participant ECR as Amazon ECR
  participant ECS as Amazon ECS

  Dev->>GHA: main 브랜치 푸시 / 수동 실행
  GHA->>ECR: AWS 자격 증명 설정 및 로그인
  GHA->>ECR: Docker 이미지 빌드(linux/amd64) 후 푸시
  GHA->>ECS: update-service --force-new-deployment
  ECS-->>GHA: wait services-stable (안정화 완료)
  GHA-->>Dev: 배포 완료
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 귀를 쫑긋, 코드를 밀어!
main에 쏙 들어가면 워크플로가 달려~
ECR엔 이미지, ECS엔 새 배포 🚀
wait services-stable 숨 참고 기다려
토끼도 CI/CD면 두 발로 충분해! 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive PR 설명이 필수 섹션을 포함하지만, 작업 내용 섹션이 매우 간단하고 상세한 설명이 부족하며 리뷰 요청 사항이 비어있음. 작업 내용 섹션에 deploy.yml의 구체적인 기능(ECS 배포, 트리거 조건, 주요 스텝)을 상세히 설명하고, 필요시 리뷰어가 집중해야 할 부분을 명시해주세요.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목 'feat: GitHub Actions CI/CD'는 추가된 주요 변경사항인 GitHub Actions 배포 워크플로우를 명확하게 설명하고 있습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/#5

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/deploy.yml:
- Line 15: Replace the hardcoded IMAGE_TAG: latest with an immutable tag using
the commit SHA (e.g., ${{ github.sha }}) to ensure each deployment tracks to a
specific commit. Update the ECR push step to use this immutable tag instead of
overwriting 'latest'. In the ECS deployment step, use register-task-definition
to create a new task definition revision that explicitly references the specific
image tag (not 'latest'), and deploy this new revision instead of relying only
on --force-new-deployment. Additionally, add a concurrency configuration to the
workflow to ensure main branch deployments execute sequentially rather than in
parallel, preventing race conditions where older commits could be redeployed.
- Around line 18-24: The workflow lacks explicit GITHUB_TOKEN permission
restrictions and the checkout step stores credentials in the git configuration,
which could expose them when the Docker build context includes the .git
directory. Add a `permissions:` block at the deploy job level to explicitly
limit token scope to minimum necessary permissions, and configure the checkout
step with `persist-credentials: false` to prevent storing the token in git
config, thereby reducing the risk of credential exposure in the Docker build
context.
- Around line 23-37: Pin all GitHub Actions to their full commit SHA values
instead of version tags to mitigate supply chain security risks in this
deployment workflow. Replace the `@v4`, `@v5`, `@v2`, and `@v3` version tags in
the `uses:` statements for actions/checkout,
aws-actions/configure-aws-credentials, aws-actions/amazon-ecr-login, and
docker/setup-buildx-action with their corresponding full commit SHAs. Add the
original version tag as a comment after each SHA for readability (for example,
`uses: actions/checkout@<full-commit-sha> # v4`). Consider using Renovate or
Dependabot to automatically manage and update these SHAs in the future.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5bb381ab-53e5-4020-9133-20fdfda962ad

📥 Commits

Reviewing files that changed from the base of the PR and between d26a2df and e66bec5.

📒 Files selected for processing (1)
  • .github/workflows/deploy.yml

ECR_REPOSITORY: momentlit/user
ECS_CLUSTER: default
ECS_SERVICE: momentlit-user-service
IMAGE_TAG: latest

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

fd -type f -name "deploy.yml" | head -20

Repository: MomentLit/User

Length of output: 229


🏁 Script executed:

cat -n .github/workflows/deploy.yml 2>/dev/null || cat -n ./.github/workflows/deploy.yml 2>/dev/null || find . -name "deploy.yml" -type f

Repository: MomentLit/User

Length of output: 2138


불변 태그와 새 task definition 등록으로 배포 재현성 확보하기

IMAGE_TAG: latest를 계속 덮어쓰고 --force-new-deployment만 호출하면, 동시에 실행 중인 여러 워크플로우에서 늦게 끝난 실행이 더 오래된 커밋의 이미지를 다시 배포할 수 있습니다. 이전 이미지를 덮어쓰므로 배포 추적과 롤백도 어렵습니다.

커밋 SHA(예: ${{ github.sha }})를 불변 태그로 ECR에 푸시하고, 그 이미지를 지정하는 새 task definition revision을 register-task-definition으로 등록한 후 배포하세요. 추가로 workflow concurrency를 설정하여 main 브랜치 배포가 순차 실행되도록 하면 더욱 안전합니다.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/deploy.yml at line 15, Replace the hardcoded IMAGE_TAG:
latest with an immutable tag using the commit SHA (e.g., ${{ github.sha }}) to
ensure each deployment tracks to a specific commit. Update the ECR push step to
use this immutable tag instead of overwriting 'latest'. In the ECS deployment
step, use register-task-definition to create a new task definition revision that
explicitly references the specific image tag (not 'latest'), and deploy this new
revision instead of relying only on --force-new-deployment. Additionally, add a
concurrency configuration to the workflow to ensure main branch deployments
execute sequentially rather than in parallel, preventing race conditions where
older commits could be redeployed.

Comment on lines +18 to +24
deploy:
name: Build and Deploy User
runs-on: ubuntu-latest

steps:
- name: Checkout source code
uses: actions/checkout@v4

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

find . -name "deploy.yml" -type f | head -20

Repository: MomentLit/User

Length of output: 89


🏁 Script executed:

cat -n .github/workflows/deploy.yml

Repository: MomentLit/User

Length of output: 2138


GITHUB_TOKEN 범위를 명시적으로 제한하고 checkout 자격 증명 저장을 비활성화하세요.

워크플로우에 permissions: 블록이 없어 기본 권한이 적용되며, actions/checkout@v4는 기본적으로 토큰을 작업 디렉터리의 git 설정에 저장합니다. 이후 라인 47의 docker buildx build . 명령이 .git 디렉터리를 포함한 전체 저장소를 빌드 컨텍스트로 전달하므로, 이 자격 증명이 필요 이상으로 노출될 위험이 있습니다.

수정 예시
 jobs:
   deploy:
     name: Build and Deploy User
     runs-on: ubuntu-latest
+    permissions:
+      contents: read
 
     steps:
       - name: Checkout source code
         uses: actions/checkout@v4
+        with:
+          persist-credentials: false
🧰 Tools
🪛 zizmor (1.25.2)

[warning] 23-24: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)


[warning] 18-63: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block

(excessive-permissions)


[error] 24-24: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/deploy.yml around lines 18 - 24, The workflow lacks
explicit GITHUB_TOKEN permission restrictions and the checkout step stores
credentials in the git configuration, which could expose them when the Docker
build context includes the .git directory. Add a `permissions:` block at the
deploy job level to explicitly limit token scope to minimum necessary
permissions, and configure the checkout step with `persist-credentials: false`
to prevent storing the token in git config, thereby reducing the risk of
credential exposure in the Docker build context.

Source: Linters/SAST tools

Comment on lines +23 to +37
- name: Checkout source code
uses: actions/checkout@v4

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v5
with:
aws-region: ${{ env.AWS_REGION }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

깃허브 액션을 전체 커밋 SHA로 고정하세요.

현재 @v4, @v5, @v2, @v3 같은 버전 태그를 사용하고 있는데, 이 태그들은 이동 가능해서 공급망 보안 위험을 야기합니다. 배포 권한을 가진 워크플로이므로 각 uses: 항목을 검증된 전체 커밋 SHA로 고정하고, 가독성을 위해 버전을 주석으로 추가하는 것이 권장됩니다 (예: uses: actions/checkout@<full-sha> # v4). Renovate나 Dependabot 같은 자동화 도구를 사용해 SHA 업데이트를 관리하면 유지보수가 용이합니다.

🧰 Tools
🪛 zizmor (1.25.2)

[warning] 23-24: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)


[error] 24-24: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)


[error] 27-27: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)


[error] 34-34: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)


[error] 37-37: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/deploy.yml around lines 23 - 37, Pin all GitHub Actions to
their full commit SHA values instead of version tags to mitigate supply chain
security risks in this deployment workflow. Replace the `@v4`, `@v5`, `@v2`, and
`@v3` version tags in the `uses:` statements for actions/checkout,
aws-actions/configure-aws-credentials, aws-actions/amazon-ecr-login, and
docker/setup-buildx-action with their corresponding full commit SHAs. Add the
original version tag as a comment after each SHA for readability (for example,
`uses: actions/checkout@<full-commit-sha> # v4`). Consider using Renovate or
Dependabot to automatically manage and update these SHAs in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant