-
Notifications
You must be signed in to change notification settings - Fork 2
65 lines (52 loc) · 2 KB
/
Copy pathmasterJsLambdaBuildDeploy.yml
File metadata and controls
65 lines (52 loc) · 2 KB
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
# Build, test and deploy to live the master branch on push or PR merge
# Requires manual approval after functional tests run successfully on staging
name: Master JS Lambda Function Build Test and Deploy
on:
# Triggers the workflow on push event (which should include PR merges) for the master branch
push:
branches: [master]
paths:
- "lambdaFunctions/**"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
AWS_LAMBDA_FUNCTION_NAME: phsDailyDataProcessing
S3_BUILD_BUCKET: sta-dashboard-builds
S3_BUILD_KEY: lambdaJsBuilds/master/${{ github.sha }}/lambda.zip
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- 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: ${{ secrets.AWS_REGION }}
- name: Install zip
uses: montudor/action-zip@v0.1.1
- name: Build and test artifacts
run: |
cd lambdaFunctions/phsDailyDataProcessing
npm install
npm test -- --watchAll=false
npm run build
cd build
zip -qq -r lambda.zip index.js
- name: Copy artifact
run: |
cd lambdaFunctions/phsDailyDataProcessing/build
aws s3 cp lambda.zip s3://$S3_BUILD_BUCKET/$S3_BUILD_KEY
deployToLive:
needs: [build]
runs-on: ubuntu-latest
steps:
- 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: ${{ secrets.AWS_REGION }}
- name: Deploy to AWS Live
run: aws lambda update-function-code --function-name $AWS_LAMBDA_FUNCTION_NAME --s3-bucket $S3_BUILD_BUCKET --s3-key $S3_BUILD_KEY