-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (58 loc) · 1.98 KB
/
Copy pathdeploy_node_lambda.yml
File metadata and controls
68 lines (58 loc) · 1.98 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
66
67
68
name: "Deploy node lambda"
on:
workflow_call:
inputs:
lambda_name:
description: "name of the lambda function to deploy - this should already exist on the AWS account through terraform"
required: true
type: string
source_dir:
description: "source directory of the lambda (usually 'src')"
required: true
type: string
aws_role_to_assume:
description: "AWS role ARN to assume for the push - you can find this in the AWS console called ga-${lambda-name}-role"
required: true
type: string
aws_region:
description: "AWS region"
default: "eu-west-1"
type: string
node_version:
description: "The version of node to deploy with"
default: 14
type: number
secrets:
node_auth_token:
description: "Auth token for using npx. Should exist in secrets"
required: true
env:
NODE_AUTH_TOKEN: ${{ inputs.node_auth_token }}
permissions:
id-token: write
contents: read
jobs:
push-lambda:
name: "Push lambda"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node14
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node_version }}
registry-url: "https://npm.pkg.github.com"
scope: "@whereby"
- name: Configure AWS access
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ inputs.aws_role_to_assume }}
aws-region: ${{ inputs.aws_region }}
- name: Install dependencies
working-directory: ${{ inputs.source_dir }}
run: npx yarn install --production --frozen-lockfile
- name: Zip function
run: cd ${{ inputs.source_dir }}; zip -r ../${{ inputs.lambda_name }}.zip .
- name: Deploy Lambda
run: aws lambda update-function-code --function-name ${{ inputs.lambda_name }} --zip-file fileb://${{ inputs.lambda_name }}.zip