Skip to content

Commit 7a24a8f

Browse files
committed
feat: GitHub Pages에서 AWS S3 + CF 구성으로 변경
1 parent a1eabed commit 7a24a8f

File tree

1 file changed

+50
-22
lines changed

1 file changed

+50
-22
lines changed

.github/workflows/deploy.yml

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,60 @@
1-
name: Deploy to GitHub Pages
1+
name: Deploy to AWS S3
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
5+
cancel-in-progress: true
26

37
on:
8+
workflow_dispatch:
9+
inputs:
10+
WORKFLOW_PHASE:
11+
description: "Environment to deploy to"
12+
required: true
13+
default: dev
14+
type: choice
15+
options:
16+
- dev
17+
- prod
418
push:
5-
branches: [main]
19+
branches:
20+
- "main"
621

722
jobs:
823
build:
924
runs-on: ubuntu-latest
25+
26+
env:
27+
API_STAGE: ${{ github.event_name == 'workflow_dispatch' && inputs.WORKFLOW_PHASE || 'dev' }}
28+
BUMP_RULE: ${{ (github.event_name == 'workflow_dispatch' && inputs.WORKFLOW_PHASE || 'dev') == 'dev' && '--mode development' || '' }}
29+
AWS_S3_BUCKET: ${{ github.event_name == 'workflow_dispatch' && secrets.AWS_S3_BUCKET_PROD || secrets.AWS_S3_BUCKET_DEV }}
30+
AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ github.event_name == 'workflow_dispatch' && secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID_PROD || secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID_DEV }}
31+
1032
steps:
11-
- uses: actions/checkout@v4
12-
- run: npm install -g pnpm && pnpm install
33+
- uses: actions/checkout@master
34+
35+
- uses: aws-actions/configure-aws-credentials@master
36+
with:
37+
role-session-name: GitHubActions
38+
role-to-assume: ${{ secrets.AWS_FRONTEND_DEPLOYMENT_ROLE_ARN }}
39+
aws-region: ${{ vars.AWS_REGION }}
40+
41+
- uses: pnpm/action-setup@v4
42+
43+
- uses: actions/setup-node@v4
44+
with:
45+
node-version: '20'
46+
cache: 'pnpm'
47+
cache-dependency-path: 'pnpm-lock.yaml'
48+
49+
- name: Install project dependencies
50+
run: pnpm install --frozen-lockfile
51+
1352
- run: mkdir -p dist
14-
- run: pnpm build:@apps/pyconkr && cp -r apps/pyconkr/dist/* dist/
53+
54+
- run: pnpm build:@apps/pyconkr ${{ env.BUMP_RULE }} && cp -r apps/pyconkr/dist/* dist/
55+
1556
- run: pnpm build:@frontend && cp packages/common/dist/common.esm.js{,.map} dist/ && cp packages/shop/dist/shop.esm.js{,.map} dist/
16-
- uses: actions/configure-pages@v5
17-
- uses: actions/upload-pages-artifact@v3
18-
with:
19-
path: "./dist"
20-
21-
deploy:
22-
needs: build
23-
permissions:
24-
pages: write
25-
id-token: write
26-
environment:
27-
name: github-pages
28-
url: ${{ steps.deployment.outputs.page_url }}
29-
runs-on: ubuntu-latest
30-
steps:
31-
- uses: actions/deploy-pages@v4
32-
id: deployment
57+
58+
- run: aws s3 cp --recursive ./dist s3://${{ env.AWS_S3_BUCKET }}/
59+
60+
- run: aws cloudfront create-invalidation --distribution-id ${{ env.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*"

0 commit comments

Comments
 (0)