Issue 217 - CDK Stack and Constructs #2
Workflow file for this run
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: PR Build and Deploy | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
pull_request_target: | |
types: [closed] | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
deploy: | |
if: github.event.action != 'closed' | |
runs-on: ubuntu-latest | |
environment: ghpublic | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-session-name: lambda-dispatch-ghpublic-build | |
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/builder-writeRole | |
aws-region: us-east-2 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
- name: Install Dependencies | |
run: yarn install --frozen-lockfile | |
- name: Build CDK Stack | |
run: | | |
cd src/cdk-stack | |
yarn install | |
yarn build | |
- name: Deploy Stack | |
env: | |
PR_NUMBER: ${{ github.event.pull_request.number }} | |
run: | | |
cd src/cdk-stack | |
yarn cdk deploy "*" --require-approval never | |
cleanup: | |
if: github.event.action == 'closed' | |
runs-on: ubuntu-latest | |
environment: ghpublic | |
steps: | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-session-name: lambda-dispatch-ghpublic-build | |
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/builder-writeRole | |
aws-region: us-east-2 | |
- name: Delete Stacks | |
run: | | |
# Delete all stacks for this PR | |
PR_NUMBER=${{ github.event.pull_request.number }} | |
aws cloudformation delete-stack --stack-name "lambda-dispatch-pr-${PR_NUMBER}" | |
aws cloudformation delete-stack --stack-name "lambda-dispatch-vpc-pr-${PR_NUMBER}" | |
# Wait for deletion to complete | |
aws cloudformation wait stack-delete-complete --stack-name "lambda-dispatch-pr-${PR_NUMBER}" | |
aws cloudformation wait stack-delete-complete --stack-name "lambda-dispatch-vpc-pr-${PR_NUMBER}" |