-
Notifications
You must be signed in to change notification settings - Fork 1
37 lines (32 loc) · 1.18 KB
/
prod_deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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"]}'