fix: main에 푸시할 시 production 배포가 발생하는 이슈 수정 #23
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
name: Deploy to AWS S3 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} | |
cancel-in-progress: true | |
on: | |
workflow_dispatch: | |
inputs: | |
WORKFLOW_PHASE: | |
description: "Environment to deploy to" | |
required: true | |
default: dev | |
type: choice | |
options: | |
- dev | |
- prod | |
push: | |
branches: | |
- "main" | |
permissions: | |
id-token : write | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
API_STAGE: ${{ github.event_name == 'workflow_dispatch' && inputs.WORKFLOW_PHASE || 'dev' }} | |
BUMP_RULE: ${{ (github.event_name == 'workflow_dispatch' && inputs.WORKFLOW_PHASE || 'dev') == 'dev' && '--mode development' || '' }} | |
AWS_S3_BUCKET: ${{ (github.event_name == 'workflow_dispatch' && inputs.WORKFLOW_PHASE || 'dev') == 'dev' && secrets.AWS_S3_BUCKET_DEV || secrets.AWS_S3_BUCKET_PROD }} | |
AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ (github.event_name == 'workflow_dispatch' && inputs.WORKFLOW_PHASE || 'dev') == 'dev' && secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID_DEV || secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID_PROD }} | |
steps: | |
- uses: actions/checkout@master | |
- uses: aws-actions/configure-aws-credentials@master | |
with: | |
role-session-name: ${{ github.run_id }} | |
role-to-assume: ${{ secrets.AWS_FRONTEND_DEPLOYMENT_ROLE_ARN }} | |
aws-region: ${{ vars.AWS_REGION }} | |
- uses: pnpm/action-setup@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'pnpm' | |
cache-dependency-path: 'pnpm-lock.yaml' | |
- name: Install project dependencies | |
run: pnpm install --frozen-lockfile | |
- run: mkdir -p dist | |
- run: pnpm build:@apps/pyconkr ${{ env.BUMP_RULE }} && cp -r apps/pyconkr/dist/* dist/ | |
- run: pnpm build:@frontend && cp packages/common/dist/common.esm.js{,.map} dist/ && cp packages/shop/dist/shop.esm.js{,.map} dist/ | |
- run: aws s3 cp --recursive ./dist s3://${{ env.AWS_S3_BUCKET }}/ | |
- run: aws cloudfront create-invalidation --distribution-id ${{ env.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" |