-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (53 loc) · 2.04 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
65
#main.yml
name: master
on:
push:
branches: [develop]
env:
AWS_REGION: ap-northeast-2
S3_BUCKET_NAME: pick-read-me-actions-s3-bucket
CODE_DEPLOY_APPLICATION_NAME: pick-read-me-codedeploy-app
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: pick-read-me-codedeploy-group-front
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Cache node modules
uses: actions/cache@v1
with:
path: node_modules
key: ${{ runner.OS }}-master-build-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: Install Dependencies
run: yarn
- name: Build
run: yarn build
- name: Include appspec.yml
run: mv appspec.yml ./build
- name: Include Scripts
run: mv deploy.sh ./build
- name: Make Zip File
run: zip -r ./$GITHUB_SHA.zip build/
shell: bash
# AWS 인증 (IAM 사용자 Access Key, Secret Key 활용)
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
# 빌드 결과물을 S3 버킷에 업로드
- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$S3_BUCKET_NAME/fe/$GITHUB_SHA.zip
# S3 버킷에 있는 파일을 대상으로 CodeDeploy 실행
- name: Deploy to AWS EC2 from S3
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,fe,key=$GITHUB_SHA.zip,bundleType=zip