-
Notifications
You must be signed in to change notification settings - Fork 1
50 lines (45 loc) · 2.2 KB
/
sam-pipeline.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
on:
push:
branches:
- develop
- main
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
# Prepare build and deploy environment
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: aws-actions/setup-sam@v2
- uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
role-to-assume: ${{ secrets.PIPELINE_EXECUTION_ROLE }}
role-duration-seconds: 3600
role-skip-session-tagging: true
# Set DynamoDB table name based on branch
- name: Set DynamoDB table name variable
run: |
if [[ "${{ github.ref_name }}" == "develop" ]]; then
echo "DYNAMODB_TABLE_NAME=${{ secrets.DEVELOP_DYNAMODB_TABLE_NAME }}" >> $GITHUB_ENV
elif [[ "${{ github.ref_name }}" == "main" ]]; then
echo "DYNAMODB_TABLE_NAME=${{ secrets.MAIN_DYNAMODB_TABLE_NAME }}" >> $GITHUB_ENV
fi
- name: Set DynamoDB table name at function
run: sed -i "s/dynamodb_table_name_placeholder/${DYNAMODB_TABLE_NAME}/g" ./docspace-reverse-proxy/index.mjs
# Set EKS load balancer endpoints
- name: Set ELB configuration
env:
DEFAULT_REGION_ELB: ${{ secrets.DEFAULT_REGION_ELB }}
EU_CENTRAL_1_REGION_ELB: ${{ secrets.EU_CENTRAL_1_REGION_ELB }}
US_EAST_2_REGION_ELB: ${{ secrets.US_EAST_2_REGION_ELB }}
run: |
sed -i "s/default_region_elb_placeholder/${DEFAULT_REGION_ELB}/g" ./docspace-reverse-proxy/index.mjs
sed -i "s/eu_central_1_region_elb_placeholder/${EU_CENTRAL_1_REGION_ELB}/g" ./docspace-reverse-proxy/index.mjs
sed -i "s/us_east_2_region_elb_placeholder/${US_EAST_2_REGION_ELB}/g" ./docspace-reverse-proxy/index.mjs
# Build and deploy stack
- run: sam build -u --template-file ${GITHUB_REF_NAME}-template.yaml
- run: sam deploy --template-file ${GITHUB_REF_NAME}-template.yaml --config-file ${GITHUB_REF_NAME}-config.toml --role-arn ${{ secrets.CLOUDFORMATION_EXECUTION_ROLE }}