Manual edit 20231129 (#4) #39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
export DYNAMODB_TABLE_NAME="${{ secrets.DEVELOP_DYNAMODB_TABLE_NAME }}" | |
elif [[ "${{ github.ref_name }}" == "main" ]]; then | |
export DYNAMODB_TABLE_NAME="${{ secrets.MAIN_DYNAMODB_TABLE_NAME }}" | |
fi | |
sed -i "s/dynamodb_table_name_placeholder/${DYNAMODB_TABLE_NAME}/g" ./docspace-reverse-proxy/index.mjs | |
- name: Set ELB configuration | |
run: | | |
if [[ "${{ github.ref_name }}" == "develop" ]]; then | |
export DEFAULT_REGION_ELB="${{ secrets.DEVELOP_DEFAULT_REGION_ELB }}" | |
export EU_CENTRAL_1_REGION_ELB="${{ secrets.DEVELOP_EU_CENTRAL_1_REGION_ELB }}" | |
export US_EAST_2_REGION_ELB="${{ secrets.DEVELOP_US_EAST_2_REGION_ELB }}" | |
elif [[ "${{ github.ref_name }}" == "main" ]]; then | |
export DEFAULT_REGION_ELB="${{ secrets.MAIN_DEFAULT_REGION_ELB }}" | |
export EU_CENTRAL_1_REGION_ELB="${{ secrets.MAIN_EU_CENTRAL_1_REGION_ELB }}" | |
export US_EAST_2_REGION_ELB="${{ secrets.MAIN_US_EAST_2_REGION_ELB }}" | |
fi | |
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 }} |