Skip to content
Closed

test #415

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/cleanup-preview.yml
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 ๋ฐฐํฌ๊ฐ€ ์ •๋ฆฌ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.'
});
100 changes: 100 additions & 0 deletions .github/workflows/deploy-preview.yml
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
});
}
45 changes: 25 additions & 20 deletions src/routes/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,28 +102,33 @@ const protectedAppRoutes = appRoutes.map((route) => ({
),
}));

const router = createBrowserRouter([
const router = createBrowserRouter(
[
{
element: (
<>
<ErrorBoundaryWrapper />
<BackActionHandler />
</>
),
children: [
{
path: '/',
element: <LanguageWrapper />,
children: protectedAppRoutes, // ๊ธฐ๋ณธ ์–ธ์–ด(ko) ๋ผ์šฐํŠธ
},
{
path: ':lang', // ๋‹ค๋ฅธ ์–ธ์–ด ๋ผ์šฐํŠธ
element: <LanguageWrapper />,
children: protectedAppRoutes,
},
Comment on lines +115 to +124
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

๊ธฐ๋ณธ ์–ธ์–ด ๋ผ์šฐํŠธ(/)์™€ ๋‹ค๋ฅธ ์–ธ์–ด ๋ผ์šฐํŠธ(/:lang)์˜ ์ •์˜๊ฐ€ ๊ฒฝ๋กœ๋ฅผ ์ œ์™ธํ•˜๊ณ ๋Š” ๊ฑฐ์˜ ๋™์ผํ•˜์—ฌ ์ฝ”๋“œ ์ค‘๋ณต์ด ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ์œ ์ง€๋ณด์ˆ˜์„ฑ์„ ๋†’์ด๊ธฐ ์œ„ํ•ด ๊ฒฝ๋กœ ๋ฐฐ์—ด์„ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ผ์šฐํŠธ๋“ค์„ ๋™์ ์œผ๋กœ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์•ž์œผ๋กœ ๋ผ์šฐํŠธ ๊ตฌ์กฐ๋ฅผ ๋ณ€๊ฒฝํ•  ๋•Œ(์˜ˆ: ์ƒˆ๋กœ์šด ๋ž˜ํผ ์ปดํฌ๋„ŒํŠธ ์ถ”๊ฐ€) ํ•œ ๊ณณ์—์„œ๋งŒ ์ˆ˜์ •ํ•˜๋ฉด ๋˜๋ฏ€๋กœ ํŽธ๋ฆฌํ•ฉ๋‹ˆ๋‹ค.

        ...['/', ':lang'].map((path) => ({
          path,
          element: <LanguageWrapper />,
          children: protectedAppRoutes,
        }))

],
},
],
{
element: (
<>
<ErrorBoundaryWrapper />
<BackActionHandler />
</>
),
children: [
{
path: '/',
element: <LanguageWrapper />,
children: protectedAppRoutes, // ๊ธฐ๋ณธ ์–ธ์–ด(ko) ๋ผ์šฐํŠธ
},
{
path: ':lang', // ๋‹ค๋ฅธ ์–ธ์–ด ๋ผ์šฐํŠธ
element: <LanguageWrapper />,
children: protectedAppRoutes,
},
],
basename: import.meta.env.VITE_BASE_PATH || '/',
},
]);
);

// ๋ผ์šฐํŠธ ๋ณ€๊ฒฝ ์‹œ Google Analytics ์ด๋ฒคํŠธ ์ „์†ก
router.subscribe(({ location }) => {
Expand Down
Loading