Skip to content

Merge pull request #116 from docwho2/dependabot/maven/org.projectlomb… #182

Merge pull request #116 from docwho2/dependabot/maven/org.projectlomb…

Merge pull request #116 from docwho2/dependabot/maven/org.projectlomb… #182

Workflow file for this run

name: Deploy CDK Stack
on:
push:
branches: [ "main" ]
paths-ignore:
- '**.png'
- '**.md'
- '**.sh'
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
concurrency: deploy
jobs:
deploy:
strategy:
matrix:
# deploy various scenarios to test no VC, with VC (pbx), and WC with Twilio
environment: [ frankfurt, frankfurt-pbx , frankfurt-twilio, london, london-pbx, london-twilio ]
runs-on: ubuntu-latest
environment: ${{ matrix.environment }}
# concurrency: ${{ (startsWith(matrix.environment,'london') && 'london') || 'frankfurt' }}
env:
TWILIO_AUTH_TOKEN: ${{ secrets.TWILIO_AUTH_TOKEN }}
TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
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
if: startsWith(matrix.environment,'frankfurt')
# For Frankfurt we test full tear down of staack and deploy, London we test already deployed stack
run: cdk destroy -c accountId=${AWS_ACCOUNT_ID} -c stackName=${{ vars.STACK_NAME }} -c regionEast=${{ vars.REGION }} --force --ci=true --all
- name: Sleeping for 15 seconds if Frankfurt
if: startsWith(matrix.environment,'frankfurt')
# Since we just tore down stack, sleep just a bit before deploying again
run: sleep 15
- name: Deploy CDK Stack
if: ${{ env.TWILIO_ACCOUNT_SID == '' && env.TWILIO_AUTH_TOKEN == ''}}
run: cdk deploy -c accountId=${AWS_ACCOUNT_ID} -c stackName=${{ vars.STACK_NAME }} -c regionEast=${{ vars.REGION }} --require-approval=never --ci=true east
env:
# SIP PBX like Asterisk with public static IP, this will configure VC to allow calls from this and send calls to it (use IP, not a hostname actually)
PBX_HOSTNAME: ${{ vars.PBX_HOSTNAME }}
- name: Deploy Twilio CDK Stack
if: ${{ env.TWILIO_ACCOUNT_SID != '' && env.TWILIO_AUTH_TOKEN != ''}}
run: cdk deploy -c twilioEastOnly=true -c accountId=${AWS_ACCOUNT_ID} -c stackName=${{ vars.STACK_NAME }} -c regionEast=${{ vars.REGION }} --require-approval=never --ci=true twilio
env:
# SIP PBX like Asterisk with public static IP, this will configure VC to allow calls from this and send calls to it (use IP, not a hostname actually)
PBX_HOSTNAME: ${{ vars.PBX_HOSTNAME }}
# Twilio Create SIP trunk pointing to Voice Connector
TWILIO_ACCOUNT_SID: ${{ env.TWILIO_ACCOUNT_SID }}
TWILIO_AUTH_TOKEN: ${{ env.TWILIO_AUTH_TOKEN }}