-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
71 lines (64 loc) · 2.2 KB
/
action.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
name: "Deploy Lambda"
description: "Deploys Lambda function using to Adapt AWS account"
author: "Adapt"
inputs:
aws-region:
description: "AWS region for the lambda function (e.g. eu-west-1)"
required: false
default: "eu-west-1"
lambda-name:
description: "Name of the lambda function to deploy"
required: true
node-runtime:
description: "Node runtime for the lambda function (e.g. nodejs18.x)"
required: true
role-to-assume:
description: "Role to assume to get access to AWS resources"
required: true
runs:
using: "composite"
steps:
- name: Configure AWS OIDC credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ inputs.role-to-assume }}
aws-region: ${{ inputs.aws-region }}
role-session-name: DeployLambdaCD
- name: Install ClaudiaJs
shell: bash
run: npm install -g claudia
- name: Remove existing claudia config
shell: bash
run: rm claudia.json || true
- name: Create
if: contains(github.event.head_commit.message, 'create_lambda')
shell: bash
run: |
claudia create --handler index.handler --runtime $NODE_RUNTIME --region $AWS_REGION --role LambdaExecutionRole --name $LAMBDA_NAME
env:
NODE_RUNTIME: ${{ inputs.node-runtime }}
LAMBDA_NAME: ${{ inputs.lambda-name }}
AWS_REGION: ${{ inputs.aws-region }}
- name: Set Config
if: ${{ !contains(github.event.head_commit.message, 'create_lambda') }}
shell: bash
run: |
echo "{
\"lambda\": {
\"role\": \"LambdaExecutionRole\",
\"name\": \"$LAMBDA_NAME\",
\"region\": \"$AWS_REGION\",
\"sharedRole\": true
}
}" > claudia.json
env:
LAMBDA_NAME: ${{ inputs.lambda-name }}
AWS_REGION: ${{ inputs.aws-region }}
- name: Update Lambda
if: ${{ !contains(github.event.head_commit.message , 'create_lambda') && !contains(github.event.head_commit.message, 'destroy_lambda') }}
shell: bash
run: claudia update
- name: Destroy Lambda
if: contains(github.event.head_commit.message, 'destroy_lambda')
shell: bash
run: claudia destroy