-
Notifications
You must be signed in to change notification settings - Fork 1
64 lines (53 loc) · 2.29 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: CD
# activate when pushed to main branch
on:
push:
branches: [main]
jobs:
build:
name: build & upload to s3
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.MAIN_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.MAIN_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.MAIN_AWS_S3_REGION }}
# create env for production
- name: make env
run: touch ./.env.production
shell: bash
- name: deliver application-prod.properties
run: echo "${{ secrets.MAIN_ENVIRONMENT }}" > ./.env.production
shell: bash
# install node modules & build nodeJS project
- name: build
working-directory: ./
run: |
yarn
yarn run build
# compress to zip file to upload to S3
- name: compress files for deploy
run: zip -r picme.zip ./dist ./scripts ./appspec.yml ./.env.production ./package.json ./prisma
# upload to s3
- name: upload to s3
run: aws s3 cp picme.zip s3://${{ secrets.MAIN_AWS_S3_BUCKET }}
# jobs for CodeDeploy to do
deploy:
needs: build
name: deploy to ec2
runs-on: ubuntu-latest
steps:
# login in AWS
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.MAIN_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.MAIN_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.MAIN_AWS_S3_REGION }}
# process deploy
- name: deploy
run: aws deploy create-deployment --application-name picme --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name mainDeployGroup --s3-location bucket=${{ secrets.MAIN_AWS_S3_BUCKET }},bundleType=zip,key=picme.zip --region ${{ secrets.MAIN_AWS_S3_REGION }} --file-exists-behavior OVERWRITE