-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (52 loc) · 1.85 KB
/
main.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: deploy to S3
on:
push:
branches:
- main
env:
S3_BUCKET_NAME: dear-web
CODE_DEPLOY_APPLICATION_NAME: dear-web
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: dear-web-group
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: Install dependencies
run: yarn install
- name: Create config directory and config.json
run: |
mkdir -p ./src/config
echo "{\"server\": \"${{ secrets.CONFIG_JSON }}\"}" > ./src/config/config.json
# 프로젝트 빌드
- name: Build next app
run: yarn build
# 프로젝트 압축
- name: Make zip file
run: zip -qq -r ./chagok.zip . -x "node_modules/*"
# AWS 자격 증명 설정
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
# 압축된 파일을 S3에 업로드
- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./chagok.zip s3://$S3_BUCKET_NAME/chagok.zip
# S3에 업로드된 빌드 파일을 이용해 CodeDeploy가 정의된 동작을 하도록 트리거
- name: Code Deploy
run: |
aws deploy create-deployment \
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} \
--s3-location bucket=$S3_BUCKET_NAME,bundleType=zip,key=chagok.zip