[Deploy] PR preview url 생성 workflows 구축#174
Hidden character warning
Conversation
Walkthrough새로운 GitHub Actions 워크플로우 Changes
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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.
Actionable comments posted: 3
🧹 Nitpick comments (2)
.github/workflows/preview.yml (2)
7-9: PR 트리거 설정을 더 구체적으로 지정하는 것이 좋습니다.현재 설정은 모든 PR 이벤트에 대해 실행됩니다. 리소스 효율성을 위해 필요한 이벤트 타입만 지정하는 것이 좋습니다.
다음과 같이 수정하는 것을 제안합니다:
on: pull_request: branches: [develop] + types: [opened, synchronize, reopened]
54-63: PR 코멘트에 추가 정보를 포함하면 좋겠습니다.현재 코멘트는 기본적인 정보만 포함하고 있습니다. 배포 시간과 환경 정보를 추가하면 더 유용할 것 같습니다.
다음과 같이 수정하는 것을 제안합니다:
message: | ## 🚀 Preview URL **Branch:** ${{ github.head_ref }} **Commit:** ${{ github.sha }} + **배포 시간:** $(date '+%Y-%m-%d %H:%M:%S') + **Node 버전:** ${{ matrix.node-version }} Preview URL: https://codeit.click?pr=${{ github.event.pull_request.number }} + + > 이 프리뷰는 자동으로 생성되었으며, PR이 머지되면 자동으로 제거됩니다.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/preview.yml(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/preview.yml
42-42: the runner of "aws-actions/configure-aws-credentials@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🔇 Additional comments (1)
.github/workflows/preview.yml (1)
15-30: 개발 환경 설정이 잘 구성되어 있습니다.
Node.js와 pnpm 설정이 적절하게 구성되어 있으며, 캐싱도 잘 적용되어 있습니다.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
.github/workflows/preview.yml (2)
48-50: S3 배포 단계에 오류 처리를 추가해야 합니다.S3 동기화 실패 시 워크플로우가 적절히 실패하도록 오류 처리를 추가하는 것이 좋습니다.
다음과 같이 수정하는 것을 제안합니다:
- run: aws s3 sync ./${{ secrets.BUILD_DIRECTORY }} s3://${{ secrets.AWS_S3_BUCKET_NAME }}/pr-${{ github.event.pull_request.number }} --delete + run: | + if ! aws s3 sync ./${{ secrets.BUILD_DIRECTORY }} s3://${{ secrets.AWS_S3_BUCKET_NAME }}/pr-${{ github.event.pull_request.number }} --delete; then + echo "S3 동기화 중 오류가 발생했습니다" + exit 1 + fi
54-63: PR 코멘트에 추가 정보를 포함하면 좋겠습니다.미리보기 URL과 함께 배포 시간과 만료 예정 시간을 포함하면 사용자에게 더 유용할 것 같습니다.
다음과 같이 수정하는 것을 제안합니다:
message: | ## 🚀 Preview URL **Branch:** ${{ github.head_ref }} **Commit:** ${{ github.sha }} + **배포 시간:** ${{ steps.current-time.outputs.time }} + **만료 예정:** 다음 PR 배포 시 Preview URL: https://codeit.click?pr=${{ github.event.pull_request.number }}시간 출력을 위해 이전 단계로 다음을 추가해야 합니다:
- name: Get current time id: current-time run: echo "time=$(date +'%Y-%m-%d %H:%M:%S %Z')" >> $GITHUB_OUTPUT
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/preview.yml(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/preview.yml
42-42: the runner of "aws-actions/configure-aws-credentials@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🔇 Additional comments (5)
.github/workflows/preview.yml (5)
1-10: 워크플로우 권한 및 트리거 설정이 적절합니다.
PR 미리보기 URL 생성을 위한 권한과 트리거가 올바르게 구성되어 있습니다.
18-31: Node.js 및 pnpm 설정이 최적화되어 있습니다.
캐싱을 활용하고 --frozen-lockfile을 사용하여 의존성 설치를 안전하게 수행하고 있습니다.
32-37: 환경 변수 유효성 검사가 필요합니다.
환경 변수가 올바르게 설정되었는지 확인하는 검증 단계를 추가해야 합니다.
다음과 같이 수정하는 것을 제안합니다:
- name: Generate Environment Variables File
run: |
+ if [ -z "$NEXT_PUBLIC_API_URL" ]; then
+ echo "Error: NEXT_PUBLIC_API_URL이 설정되지 않았습니다"
+ exit 1
+ fi
echo "NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL" >> apps/web/.env.production.local
env:
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}41-47: AWS Credentials 액션 버전 업데이트가 필요합니다.
현재 사용 중인 aws-actions/configure-aws-credentials@v1은 더 이상 권장되지 않습니다.
다음과 같이 수정하는 것을 제안합니다:
- uses: aws-actions/configure-aws-credentials@v1
+ uses: aws-actions/configure-aws-credentials@v4🧰 Tools
🪛 actionlint (1.7.4)
42-42: the runner of "aws-actions/configure-aws-credentials@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
51-52: CloudFront 캐시 무효화 범위를 최적화해야 합니다.
현재 모든 경로('/*')에 대해 캐시 무효화를 수행하고 있습니다. PR 관련 경로만 무효화하는 것이 효율적입니다.
다음과 같이 수정하는 것을 제안합니다:
- run: aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths '/*'
+ run: aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths '/pr-${{ github.event.pull_request.number }}/*'There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
.github/workflows/preview.yml (2)
18-31: 의존성 설치 단계의 캐싱 전략을 개선할 수 있습니다.현재는 Node 모듈에 대한 기본 캐싱만 설정되어 있습니다. 빌드 성능을 향상시키기 위해 다음 사항들을 고려해보세요:
- pnpm store 디렉토리 캐싱
- Next.js 빌드 캐시 활용
- name: Install pnpm uses: pnpm/action-setup@v4 with: version: 8.15.6 + run_install: false - name: Use Node.js uses: actions/setup-node@v4 with: node-version: "20.x" cache: "pnpm" + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + - name: Setup pnpm cache + uses: actions/cache@v3 + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies run: pnpm install --frozen-lockfile
54-63: 프리뷰 URL 메시지를 개선할 수 있습니다.프리뷰 URL 메시지에 다음 정보를 추가하면 더 유용할 것 같습니다:
- 배포 시간
- 만료 예정 시간 (있는 경우)
- 관리자 페이지 프리뷰 URL
message: | ## 🚀 Preview URL **Branch:** ${{ github.head_ref }} **Commit:** ${{ github.sha }} + **배포 시간:** ${{ steps.date.outputs.date }} + **만료 예정:** 다음 PR 배포 시 프리뷰 URL: - 메인: https://codeit.click?pr=${{ github.event.pull_request.number }} + - 관리자: https://codeit.click/admin/members?pr=${{ github.event.pull_request.number }}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/preview.yml(1 hunks)package.json(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/preview.yml
42-42: the runner of "aws-actions/configure-aws-credentials@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🔇 Additional comments (5)
.github/workflows/preview.yml (5)
1-10: 워크플로우 구성이 적절합니다.
권한 설정과 트리거 조건이 PR 프리뷰 URL 생성 목적에 맞게 잘 구성되어 있습니다.
32-39: 환경 변수 검증 로직이 여전히 필요합니다.
이전 리뷰에서 지적된 환경 변수 검증 로직이 아직 구현되지 않았습니다.
41-46: AWS Credentials 액션 버전 업데이트가 여전히 필요합니다.
이전 리뷰에서 지적된 aws-actions/configure-aws-credentials 액션 버전 업데이트가 아직 적용되지 않았습니다.
🧰 Tools
🪛 actionlint (1.7.4)
42-42: the runner of "aws-actions/configure-aws-credentials@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
51-52: CloudFront 캐시 무효화 범위가 여전히 최적화되지 않았습니다.
이전 리뷰에서 지적된 CloudFront 캐시 무효화 범위 최적화가 아직 적용되지 않았습니다.
48-50: S3 배포 경로에 대한 보안 고려사항이 필요합니다.
PR 번호를 기반으로 한 S3 경로 설정은 적절하나, 다음 보안 고려사항을 추가하는 것이 좋습니다:
- PR 번호의 유효성 검증
- 배포 디렉토리 경로 주입 공격 방지
✅ Verification successful
Let me check the workflow file content to better understand the context and validation requirements.
GitHub Actions 워크플로우의 보안 검증이 이미 충분합니다.
GitHub Actions의 기본 보안 기능과 워크플로우 구성이 제기된 보안 우려사항을 이미 적절히 다루고 있습니다:
- PR 번호는 GitHub Actions에서 자동으로 생성되는 시스템 변수(
github.event.pull_request.number)로, GitHub에 의해 자동으로 검증됩니다. BUILD_DIRECTORY는 GitHub Secrets로 관리되어 안전하게 보호되며, GitHub Actions의 실행 컨텍스트 내에서만 접근 가능합니다.- AWS 자격 증명도 GitHub Secrets를 통해 안전하게 관리되고 있습니다.
추가적인 검증 로직은 불필요하며, 현재 구성이 보안 모범 사례를 잘 따르고 있습니다.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# PR 번호가 숫자인지 확인
if ! [[ ${{ github.event.pull_request.number }} =~ ^[0-9]+$ ]]; then
echo "Error: Invalid PR number"
exit 1
fi
# BUILD_DIRECTORY가 상위 디렉토리를 참조하지 않는지 확인
if [[ "${{ secrets.BUILD_DIRECTORY }}" == *".."* ]]; then
echo "Error: Invalid build directory path"
exit 1
fi
Length of output: 248
Script:
#!/bin/bash
# Check the workflow file content
cat .github/workflows/preview.yml
Length of output: 1882
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (2)
.github/workflows/preview.yml (2)
32-37: 🛠️ Refactor suggestion환경 변수 유효성 검사가 필요합니다.
환경 변수가 올바르게 설정되었는지 확인하는 검증 단계를 추가해야 합니다.
다음과 같이 수정을 제안합니다:
- name: Generate Environment Variables File run: | + if [ -z "$NEXT_PUBLIC_API_URL" ]; then + echo "Error: NEXT_PUBLIC_API_URL이 설정되지 않았습니다" + exit 1 + fi echo "NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL" >> apps/web/.env.production.local env: NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}
41-47:⚠️ Potential issueAWS Credentials 액션 버전 업데이트가 필요합니다.
현재 사용 중인
aws-actions/configure-aws-credentials@v1은 더 이상 권장되지 않습니다.다음과 같이 수정을 제안합니다:
- uses: aws-actions/configure-aws-credentials@v1 + uses: aws-actions/configure-aws-credentials@v4🧰 Tools
🪛 actionlint (1.7.4)
42-42: the runner of "aws-actions/configure-aws-credentials@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🧹 Nitpick comments (1)
.github/workflows/preview.yml (1)
54-63: 프리뷰 URL 코멘트 개선을 제안합니다.현재 코멘트에 유용한 정보를 추가하면 좋을 것 같습니다.
다음과 같이 수정을 제안합니다:
message: | ## 🚀 Preview URL **Branch:** ${{ github.head_ref }} **Commit:** ${{ github.sha }} + **배포 시간:** `$(date '+%Y-%m-%d %H:%M:%S %Z')` + **Admin 페이지:** https://codeit.click/admin/members?pr=${{ github.event.pull_request.number }} Preview URL: https://codeit.click?pr=${{ github.event.pull_request.number }} + + > 이 프리뷰는 PR이 머지되거나 클로즈되면 자동으로 제거됩니다.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/preview.yml(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/preview.yml
42-42: the runner of "aws-actions/configure-aws-credentials@v1" action is too old to run on GitHub Actions. update the action's version to fix this issue
(action)
🔇 Additional comments (4)
.github/workflows/preview.yml (4)
1-10: 워크플로우 권한 설정이 적절합니다.
권한이 최소 권한 원칙에 따라 잘 설정되어 있습니다:
pull-requests: write: PR 코멘트를 위해 필요contents: read: 코드 체크아웃을 위해 필요
48-50: 빌드 디렉토리 경로 검증이 필요합니다.
BUILD_DIRECTORY 시크릿이 올바른 경로를 가리키는지 확인해주세요. Next.js 프로젝트의 경우 일반적으로 .next 또는 out 디렉토리를 사용합니다.
51-52: 캐시 무효화 경로가 최적화되어 있습니다.
PR 관련 경로(/pr-{PR_NUMBER}/*)만 무효화하도록 잘 구현되어 있습니다.
18-28: Node.js 버전 호환성 확인이 필요합니다.
Node.js 20.x 버전이 프로젝트의 다른 종속성과 호환되는지 확인해주세요.
✅ Verification successful
Node.js 20.x 버전은 프로젝트의 엔진 요구사항과 호환됩니다.
일부 package.json 파일에서 Node.js >=18 버전을 요구하고 있으며, Node.js 20.x는 이 요구사항을 충족합니다. 다른 package.json 파일들은 Node.js 버전에 대한 제한을 명시하지 않았습니다.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# package.json에서 Node.js 엔진 요구사항 확인
fd package.json --exec cat {} | jq '.engines.node'
Length of output: 121
🚀 Preview URLBranch: 173-deploy-pr-미리보기-url-자동-생성-워크플로우-구축 Preview URL: https://codeit.click?pr=174 |
.github/workflows/preview.yml
Outdated
| - name: Install pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 9.12.1 |
| "prettier": "@org/prettier-config", | ||
| "workspaces": [ | ||
| "packages/*", | ||
| "apps/*" | ||
| ] |
There was a problem hiding this comment.
workspaces는 모노레포 패키지에서 삭제하면 안돼!
package.json
Outdated
| "typescript": "^5.6.3" | ||
| }, | ||
| "packageManager": "pnpm@8.15.6", | ||
| "packageManager": "pnpm@9.12.1", |
There was a problem hiding this comment.
packageManager는 기존 버젼 유지하는건 어때?
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
.github/workflows/preview.yml (1)
38-40: 빌드 실패 시 오류 처리를 개선해주세요.빌드 단계에 오류 발생 시 더 명확한 피드백을 제공하면 좋을 것 같습니다.
다음과 같이 수정하는 것을 제안합니다:
- name: Build run: | + echo "웹 애플리케이션 빌드를 시작합니다..." pnpm -filter=web build + if [ $? -ne 0 ]; then + echo "빌드 실패! 로그를 확인해주세요." + exit 1 + fi + echo "빌드가 성공적으로 완료되었습니다."
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/preview.yml(1 hunks)
🔇 Additional comments (5)
.github/workflows/preview.yml (5)
1-10: 워크플로우 권한 및 트리거 설정이 적절합니다.
필요한 최소 권한만 설정되어 있고, develop 브랜치에 대한 PR에서만 실행되도록 적절히 구성되어 있습니다.
32-37: 환경 변수 유효성 검사가 필요합니다.
환경 변수가 올바르게 설정되었는지 확인하는 검증 로직이 없습니다.
다음과 같이 수정하는 것을 제안합니다:
- name: Generate Environment Variables File
run: |
+ if [ -z "$NEXT_PUBLIC_API_URL" ]; then
+ echo "Error: NEXT_PUBLIC_API_URL이 설정되지 않았습니다"
+ exit 1
+ fi
echo "NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL" >> apps/web/.env.production.local
env:
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}41-50: AWS 구성이 적절하게 설정되어 있습니다.
최신 버전의 AWS 인증 액션을 사용하고 있으며, PR별로 구분된 S3 경로를 사용하여 안전하게 구성되어 있습니다.
51-53: 캐시 무효화 범위가 최적화되어 있습니다.
이전 리뷰 의견이 반영되어 PR 관련 경로만 무효화하도록 개선되었습니다.
18-31: Node.js 버전 선택을 확인해주세요.
이전 리뷰 코멘트에 따르면 Node.js 8 버전을 사용해야 한다고 언급되어 있으나, 현재 20.x를 사용하도록 설정되어 있습니다. 프로젝트 요구사항과 일치하는지 확인이 필요합니다.
🚀 작업 내용
📝 참고 사항
ex)
Default: https://codeit.kr/?pr=pr번호
어드민 페이지 접속: https://codeit.kr/admin/members?pr=pr번호
🚨 관련 이슈 (이슈 번호)
✅ 체크리스트
Summary by CodeRabbit