.github/workflows/prod_deploy.yml #31
This file contains 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: Frontend 프로덕션 서버 EC2 배포 | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: # 수동 실행 이벤트 추가 | |
jobs: | |
deploy: | |
name: 배포 작업 | |
runs-on: ubuntu-latest | |
env: | |
# AWS 관련 | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: ap-northeast-2 | |
EC2_INSTANCE_ID: ${{ secrets.FRONTEND_EC2_INSTANCE_ID }} | |
# Next.js 관련 | |
ENV_CONTENT: ${{ secrets.FRONTEND_PRODUCTION_ENV_CONTENT }} | |
steps: | |
- name: AWS 로그인 | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: SSM으로 EC2에 배포 | |
run: | | |
aws --no-cli-pager ssm send-command \ | |
--document-name "AWS-RunShellScript" \ | |
--targets "Key=instanceIds, Values=${{ env.EC2_INSTANCE_ID}}" \ | |
--parameters '{"workingDirectory": ["/home/ubuntu/Frontend"], | |
"commands" : ["ENV_CONTENT='${{ env.ENV_CONTENT }}' bash ./.github/workflows/prod_deploy.sh"]}' |