-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (71 loc) · 2.8 KB
/
backend-dev.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: BE Dev Deploy
on:
push:
branches:
- develop
paths:
- backend/**
- .github/**
jobs:
deploy:
env:
ENV_PATH: .env.staging
environment: staging
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
steps:
- name: Git Checkout
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: yarn
cache-dependency-path: '**/yarn.lock'
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-modules-
- name: Create .env file
run: |
touch ${{ env.ENV_PATH }}
echo PORT=${{ secrets.PORT }} >> ${{ env.ENV_PATH }}
echo DB_HOST=${{ secrets.DB_HOST }} >> ${{ env.ENV_PATH }}
echo DB_PORT=${{ secrets.DB_PORT }} >> ${{ env.ENV_PATH }}
echo DB_USERNAME=${{ secrets.DB_USERNAME }} >> ${{ env.ENV_PATH }}
echo DB_PASSWORD=${{ secrets.DB_PASSWORD }} >> ${{ env.ENV_PATH }}
echo DB_DATABASE=${{ secrets.DB_DATABASE }} >> ${{ env.ENV_PATH }}
echo REDIS_BINDING_PORT=${{ secrets.REDIS_BINDING_PORT }} >> ${{ env.ENV_PATH }}
echo REDIS_PORT=${{ secrets.REDIS_PORT }} >> ${{ env.ENV_PATH }}
echo REDIS_PASSWORD=${{ secrets.REDIS_PASSWORD }} >> ${{ env.ENV_PATH }}
echo SWAGGER_USER=${{ secrets.SWAGGER_USER }} >> ${{ env.ENV_PATH }}
echo SWAGGER_PASSWORD=${{ secrets.SWAGGER_PASSWORD }} >> ${{ env.ENV_PATH }}
cat ${{ env.ENV_PATH }}
- name: Install Dependencies
run: yarn install --immutable
- name: Build
run: yarn build
- name: Copy appspec.yml
run: mv ./appspec-dev.yml ./appspec.yml
- name: Make zip file
run: zip -qq -r ./dev.zip . -x "node_modules/*"
shell: bash
- 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: ap-northeast-2
- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./dev.zip s3://${{ secrets.AWS_S3_BUCKET_NAME }}/dev.zip
- name: Deploy to EC2 with CodeDeploy
run: aws deploy create-deployment
--deployment-config-name CodeDeployDefault.AllAtOnce
--application-name ${{ secrets.AWS_CODEDEPLOY_APPLICATION_NAME }}
--deployment-group-name ${{ secrets.AWS_CODEDEPLOY_DEPLOYMENT_GROUP_NAME }}
--s3-location bucket=${{ secrets.AWS_S3_BUCKET_NAME }},bundleType=zip,key=dev.zip