-
Notifications
You must be signed in to change notification settings - Fork 0
[feat] : GitHub Actions 기반 CICD를 구축한다 #12
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 워크플로우 파일이 추가되어, develop 브랜치로의 풀 리퀘스트 발생 시 크롤러 애플리케이션의 빌드, DockerHub 이미지 푸시, AWS EC2 서버 배포까지 자동화하는 CI/CD 파이프라인이 구성되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant GitHub Actions
participant DockerHub
participant AWS EC2
Developer->>GitHub Actions: PR to develop 브랜치 생성
GitHub Actions->>GitHub Actions: 코드 체크아웃 & Python 세팅
GitHub Actions->>DockerHub: Docker 로그인, 이미지 빌드 및 latest 태그로 푸시
GitHub Actions->>AWS EC2: SSH 접속 후 deploy.sh 실행
Possibly related issues
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 (2)
.github/workflows/crawler-cicd.yaml (2)
15-19: 🐍 Python 설정 스텝 불필요 여부 검토
현재 워크플로우에서 Python 관련 명령(python실행이나 테스트)이 없어 보입니다. 실제 필요 없다면 해당 스텝을 제거하거나, 테스트/패키징 스텝을 추가하는 방안을 고려하세요.🧰 Tools
🪛 actionlint (1.7.7)
16-16: the runner of "actions/setup-python@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
26-30: 이미지 태깅 정책 개선 제안
latest태그 외에 Git SHA나 빌드 번호를 포함해 이력이 관리되도록 하면 롤백 및 추적이 용이해집니다. 또한DOCKER_IMAGE_NAME은 시크릿 대신 환경 변수로 관리하는 걸 권장합니다.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/crawler-cicd.yaml(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/crawler-cicd.yaml
13-13: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
16-16: the runner of "actions/setup-python@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
21-21: the runner of "docker/login-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build-and-deploy
🔇 Additional comments (5)
.github/workflows/crawler-cicd.yaml (5)
1-2: name 필드 명확함
워크플로우 이름이 변경 내역을 간결하게 설명합니다.
3-6: pull_request 이벤트 시 시크릿 노출 검증 필요
pull_request로 트리거하면 포크된 PR의 경우 시크릿이 비노출되어 이후 로그인 또는 배포 단계가 실패할 수 있습니다. 외부 기여자 작업 흐름을 고려해pull_request_target사용 또는 문서화가 필요합니다.
7-10: 런너 설정 적절
ubuntu-latest환경 사용은 표준적이며 문제 없습니다.
12-14: 코드 체크아웃 스텝 올바름
actions/checkout@v3사용은 최신 버전이며 권장됩니다.🧰 Tools
🪛 actionlint (1.7.7)
13-13: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
20-25: DockerHub 로그인 스텝 적절
docker/login-action@v2로 시크릿 기반 로그인을 처리하는 방식은 안전합니다.🧰 Tools
🪛 actionlint (1.7.7)
21-21: the runner of "docker/login-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
.github/workflows/crawler-cicd.yaml
Outdated
| - name: 🚀 AWS EC2에 배포 스크립트 실행 | ||
| uses: appleboy/ssh-action@master | ||
| with: | ||
| host: ${{ secrets.AWS_EC2_HOST }} | ||
| username: ${{ secrets.AWS_EC2_USERNAME }} | ||
| key: ${{ secrets.AWS_EC2_SSH_KEY }} | ||
| script: | | ||
| chmod +x ./deploy.sh | ||
| ./deploy.sh |
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.
💡 Verification agent
🧩 Analysis chain
SSH 액션 버전 고정 및 보안 강화
appleboy/ssh-action@master는 예측 불가능한 업데이트 위험이 있으므로 릴리스 태그나 커밋 SHA로 버전을 고정하세요. 또한 known_hosts 설정을 추가해 MITM 공격을 방지하는 절차를 고려해야 합니다. 배포 스크립트(deploy.sh) 경로가 작업 디렉토리 기준으로 유효한지도 확인해 주세요.
deploy.sh 파일 존재 여부와 워크플로우에서 known_hosts 사용 여부를 확인하기 위한 스크립트를 실행합니다.
🏁 Script executed:
#!/usr/bin/env bash
# deploy.sh 파일 위치 검색
echo "Searching for deploy.sh:"
fd deploy.sh || echo "deploy.sh not found"
# 워크플로우에서 known_hosts 설정 사용 여부 검색
echo "Checking for known_hosts in .github/workflows:"
rg "known_hosts" -g ".github/workflows/*.yaml" || echo "No known_hosts usage found"Length of output: 435
SSH 액션 버전 고정 및 호스트 지문 검증 추가 필요
워크플로우에 아래 사항을 반영해주세요:
-
.github/workflows/crawler-cicd.yaml(31–39줄)uses: appleboy/ssh-action@master→ 릴리스 태그(예:@v0.6.0) 또는 커밋 SHA로 버전 고정with:블록에known_hosts: ${{ secrets.AWS_EC2_KNOWN_HOSTS }}입력 추가 (MITM 방지용 호스트 지문 검증)
-
deploy.sh스크립트 경로 검증
워크플로우가 실행되는 디렉터리 기준으로deploy.sh가 존재하는지, 상대 경로가 올바른지 확인하세요.
예시 변경안:
uses: appleboy/ssh-action@master
-with:
+with:
host: ${{ secrets.AWS_EC2_HOST }}
username: ${{ secrets.AWS_EC2_USERNAME }}
key: ${{ secrets.AWS_EC2_SSH_KEY }}
+ known_hosts: ${{ secrets.AWS_EC2_KNOWN_HOSTS }}
script: |
chmod +x ./deploy.sh
./deploy.sh📝 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.
| - name: 🚀 AWS EC2에 배포 스크립트 실행 | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.AWS_EC2_HOST }} | |
| username: ${{ secrets.AWS_EC2_USERNAME }} | |
| key: ${{ secrets.AWS_EC2_SSH_KEY }} | |
| script: | | |
| chmod +x ./deploy.sh | |
| ./deploy.sh | |
| - name: 🚀 AWS EC2에 배포 스크립트 실행 | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.AWS_EC2_HOST }} | |
| username: ${{ secrets.AWS_EC2_USERNAME }} | |
| key: ${{ secrets.AWS_EC2_SSH_KEY }} | |
| known_hosts: ${{ secrets.AWS_EC2_KNOWN_HOSTS }} | |
| script: | | |
| chmod +x ./deploy.sh | |
| ./deploy.sh |
🤖 Prompt for AI Agents
In .github/workflows/crawler-cicd.yaml around lines 31 to 39, change the SSH
action version from the floating 'master' tag to a fixed release tag or commit
SHA like '@v0.6.0' to avoid unpredictable updates. Add a 'known_hosts' input
with the value '${{ secrets.AWS_EC2_KNOWN_HOSTS }}' to enable host key
verification and prevent MITM attacks. Also, verify that the 'deploy.sh' script
path is correct relative to the workflow's working directory to ensure it exists
and is executable during the deployment step.
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
♻️ Duplicate comments (1)
.github/workflows/crawler-cicd.yaml (1)
32-36: SSH 액션 버전 고정 및 호스트 검증 추가
appleboy/ssh-action@master은 예측 불가능한 업데이트 위험이 있으므로 릴리스 태그나 커밋 SHA로 버전을 고정하고, 호스트 키 검증을 위해known_hosts: ${{ secrets.AWS_EC2_KNOWN_HOSTS }}입력을 추가해야 합니다.
🧹 Nitpick comments (1)
.github/workflows/crawler-cicd.yaml (1)
40-40: 파일 끝에 개행 추가
YAML 파일 끝에 새 줄이 누락되어 있습니다. 끝에 개행을 추가해 주세요.🧰 Tools
🪛 YAMLlint (1.37.1)
[error] 40-40: no new line character at the end of file
(new-line-at-end-of-file)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/crawler-cicd.yaml(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/crawler-cicd.yaml
13-13: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
16-16: the runner of "actions/setup-python@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
21-21: the runner of "docker/login-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🪛 YAMLlint (1.37.1)
.github/workflows/crawler-cicd.yaml
[error] 40-40: no new line character at the end of file
(new-line-at-end-of-file)
🔇 Additional comments (5)
.github/workflows/crawler-cicd.yaml (5)
3-5: 풀 리퀘스트 이벤트 트리거 적절
워크플로우가pull_request이벤트로만 실행되도록 설정되었습니다. PR 기준 빌드 테스트 및 배포 검증에 적합합니다.
12-13: 코드 체크아웃 액션 버전 적절
actions/checkout@v3사용으로 최신 안정 버전을 활용하고 있습니다.🧰 Tools
🪛 actionlint (1.7.7)
13-13: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
16-18: Python 설정 액션 적절
actions/setup-python@v4및python-version: '3.12'설정이 명확합니다.🧰 Tools
🪛 actionlint (1.7.7)
16-16: the runner of "actions/setup-python@v4" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
21-24: DockerHub 로그인 액션 적절
docker/login-action@v2와 시크릿 활용이 안전한 패턴입니다.🧰 Tools
🪛 actionlint (1.7.7)
21-21: the runner of "docker/login-action@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
27-29: Docker 이미지 빌드 및 푸시 주기 검토 필요
PR 이벤트마다 DockerHub로 이미지를 푸시하고 있습니다. 의도된 동작인지, PR마다 레지스트리가 불필요하게 증가하지는 않는지 확인하세요.
| script: | | ||
| cd ~/ | ||
| sudo chmod +x deploy.sh | ||
| sudo ./deploy.sh No newline at end of 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.
원격 서버에 deploy.sh 존재 여부 확인 필요
SSH로 접속 후 deploy.sh를 실행하지만, 원격 서버에 해당 스크립트가 존재하지 않거나 올바른 경로에 없을 수 있습니다. 배포 전에 스크립트 복사(scp) 또는 원격 저장소 클론(git clone) 등을 선행해야 합니다.
🧰 Tools
🪛 YAMLlint (1.37.1)
[error] 40-40: no new line character at the end of file
(new-line-at-end-of-file)
🤖 Prompt for AI Agents
In .github/workflows/crawler-cicd.yaml around lines 37 to 40, the deploy.sh
script is executed on the remote server without verifying its existence or
ensuring it is present. Before running deploy.sh, add steps to copy the script
to the remote server using scp or clone the repository containing the script via
git clone, so the script is guaranteed to be available at the expected location.
✅ PR 유형
🚀 작업 내용
📝️ 관련 이슈
💬 기타 사항 or 추가 코멘트
Summary by CodeRabbit