Merge pull request #14 from docwho2/dependabot/maven/software.amazon.… #56
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
name: Deploy CDK Stack | |
on: | |
push: | |
branches: [ "main" ] | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
concurrency: deploy | |
jobs: | |
build: | |
strategy: | |
matrix: | |
environment: [ frankfurt, frankfurt-pbx , london, london-pbx ] | |
runs-on: ubuntu-latest | |
environment: ${{ matrix.environment }} | |
concurrency: ${{ (startsWith(matrix.environment,'london') && 'london') || 'frankfurt' }} | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'corretto' | |
cache: maven | |
- name: Install AWS CDK | |
run: | | |
npm install -g aws-cdk | |
echo "Node Version: $(node -v)" | |
echo "CDK Version: $(cdk version)" | |
- name: Setup AWS Credentials | |
id: aws-creds | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: ${{ vars.REGION }} | |
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} | |
mask-aws-account-id: true | |
- name: Add AWS_ACCOUNT_ID to Environment | |
run: echo "AWS_ACCOUNT_ID=${{ steps.aws-creds.outputs.aws-account-id }}" >> $GITHUB_ENV | |
- name: Ensure CDK is bootstraped and up to date | |
run: cdk bootstrap --ci=true -c accountId=${AWS_ACCOUNT_ID} aws://${AWS_ACCOUNT_ID}/${{ vars.REGION }} | |
- name: Destroy Stack if it exists for Frankfurt region only | |
if: startsWith(matrix.environment,'frankfurt') | |
run: cdk destroy -c accountId=${AWS_ACCOUNT_ID} -c stackName=${{ vars.STACK_NAME }} -c regionEast=${{ vars.REGION }} --force --ci=true east | |
- name: Sleeping for 10 seconds if Frankfurt | |
if: startsWith(matrix.environment,'frankfurt') | |
run: sleep 10 | |
- name: Add PBX_HOSTNAME to Environment if var is set | |
if: ${{ vars.PBX_HOSTNAME }} | |
run: echo "PBX_HOSTNAME=${{ vars.PBX_HOSTNAME }}" >> $GITHUB_ENV | |
- name: Deploy CDK Stack | |
run: cdk deploy -c accountId=${AWS_ACCOUNT_ID} -c stackName=${{ vars.STACK_NAME }} -c regionEast=${{ vars.REGION }} --require-approval=never --ci=true east | |