-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (46 loc) · 1.74 KB
/
AWS-Sync.yaml
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
name: AWS Environment Sync
run-name: Sync GitHub env with AWS Lambda
on:
workflow_dispatch:
inputs:
FUNCTION_NAME_AGNES:
required: true
description: The name of the Lambda to receive the GitHub environment
default: main
push:
tags:
- v*
# Required for aws-actions/configure-aws-credentials
permissions:
id-token: write
contents: read
jobs:
sync-environment:
name: Sync env with Lambda
runs-on: ubuntu-latest
environment: AWS
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_CD_ROLE_ARN }}
- name: Sync all environment variables with the Lambda environment
env:
FUNCTION_NAME: ${{ format('{0}-{1}', 'DsireApi-Agnes', github.event.inputs.FUNCTION_NAME_AGNES || 'main') }}
DB_DATABASE: ${{ vars.DB_DATABASE }}
DB_HOST: ${{ vars.DB_HOST }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
DB_PORT: ${{ vars.DB_PORT }}
DB_USER: ${{ vars.DB_USER }}
NODE_OPTIONS: ${{ vars.NODE_OPTIONS }}
run: |
aws lambda update-function-configuration \
--function-name="${FUNCTION_NAME}" \
--environment "Variables={DB_DATABASE='${DB_DATABASE}',
DB_HOST='${DB_HOST}',
DB_PASSWORD='${DB_PASSWORD}',
DB_PORT='${DB_PORT}',
DB_USER='${DB_USER}',
NODE_OPTIONS='${NODE_OPTIONS}'}" > /dev/null
aws lambda wait function-updated --function-name "${FUNCTION_NAME}"