-
Notifications
You must be signed in to change notification settings - Fork 2
test #415
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
Closed
Closed
test #415
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| name: Cleanup-Preview | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [closed] | ||
| branches: ['develop'] | ||
|
|
||
| jobs: | ||
| cleanup: | ||
| runs-on: ubuntu-latest | ||
| environment: DEPLOY_PREVIEW | ||
| permissions: | ||
| pull-requests: write | ||
|
|
||
| steps: | ||
| - name: Configure AWS Credentials | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| aws-access-key-id: ${{ secrets.AWS_PREVIEW_ACCESS_KEY_ID }} | ||
| aws-secret-access-key: ${{ secrets.AWS_PREVIEW_SECRET_ACCESS_KEY }} | ||
| aws-region: ap-northeast-2 | ||
|
|
||
| - name: Delete Preview from S3 | ||
| run: | | ||
| aws s3 rm s3://${{ secrets.AWS_PREVIEW_BUCKET_NAME }}/pr-${{ github.event.pull_request.number }}/ --recursive | ||
|
|
||
| - name: Comment Cleanup Notice | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.payload.pull_request.number, | ||
| body: '🧹 Preview 배포가 정리되었습니다.' | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| name: Deploy-Preview | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
| branches: ['develop'] | ||
|
|
||
| concurrency: | ||
| group: preview-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| deploy-preview: | ||
| runs-on: ubuntu-latest | ||
| environment: DEPLOY_PREVIEW | ||
| permissions: | ||
| pull-requests: write | ||
| contents: read | ||
|
|
||
| steps: | ||
| - name: Setup NodeJS | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
|
|
||
| - name: Checkout Code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup .env | ||
| run: | | ||
| echo "${{ vars.ENV }}" > .env | ||
| echo "${{ secrets.ENV }}" >> .env | ||
| echo "VITE_BASE_PATH=/pr-${{ github.event.pull_request.number }}" >> .env | ||
|
|
||
| - name: Install Dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Build Preview | ||
| run: npm run build | ||
|
|
||
| - name: Configure AWS Credentials | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| aws-access-key-id: ${{ secrets.AWS_PREVIEW_ACCESS_KEY_ID }} | ||
| aws-secret-access-key: ${{ secrets.AWS_PREVIEW_SECRET_ACCESS_KEY }} | ||
| aws-region: ap-northeast-2 | ||
|
|
||
| - name: Deploy to S3 Preview Bucket | ||
| run: | | ||
| aws s3 sync ./dist s3://${{ secrets.AWS_PREVIEW_BUCKET_NAME }}/pr-${{ github.event.pull_request.number }}/ --delete | ||
|
|
||
| - name: Invalidate CloudFront Cache | ||
| run: | | ||
| aws cloudfront create-invalidation \ | ||
| --distribution-id ${{ secrets.AWS_PREVIEW_CLOUDFRONT_ID }} \ | ||
| --paths "/pr-${{ github.event.pull_request.number }}/*" | ||
|
|
||
| - name: Comment Preview URL on PR | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const prNumber = context.payload.pull_request.number; | ||
| const domain = '${{ vars.PREVIEW_DOMAIN }}'; | ||
| const url = `https://${domain}/pr-${prNumber}/`; | ||
|
|
||
| const body = `## 🚀 Preview 배포 완료! | ||
|
|
||
| | 환경 | URL | | ||
| |-----|-----| | ||
| | Preview | [열기](${url}) | | ||
| | API | Dev 환경 | | ||
|
|
||
| > PR이 닫히면 자동으로 정리됩니다.`; | ||
|
|
||
| const { data: comments } = await github.rest.issues.listComments({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: prNumber, | ||
| }); | ||
|
|
||
| const existing = comments.find(c => | ||
| c.user.login === 'github-actions[bot]' && | ||
| c.body.includes('Preview 배포 완료') | ||
| ); | ||
|
|
||
| if (existing) { | ||
| await github.rest.issues.updateComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| comment_id: existing.id, | ||
| body | ||
| }); | ||
| } else { | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: prNumber, | ||
| body | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
기본 언어 라우트(
/)와 다른 언어 라우트(/:lang)의 정의가 경로를 제외하고는 거의 동일하여 코드 중복이 발생합니다. 유지보수성을 높이기 위해 경로 배열을 기반으로 라우트들을 동적으로 생성할 수 있습니다. 이렇게 하면 앞으로 라우트 구조를 변경할 때(예: 새로운 래퍼 컴포넌트 추가) 한 곳에서만 수정하면 되므로 편리합니다.