Skip to content

Instantly share code, notes, and snippets.

@mtliendo
Created March 27, 2023 20:32
Show Gist options
  • Save mtliendo/274a5c8f4bff90e58d3cb9fd351ecc59 to your computer and use it in GitHub Desktop.
Save mtliendo/274a5c8f4bff90e58d3cb9fd351ecc59 to your computer and use it in GitHub Desktop.
GitHub action flow to deploy a multi-env CDK app
name: Deploy CDK Project
on:
push:
branches:
- develop
pull_request:
branches:
- main
types:
- closed
jobs:
aws_cdk:
if: github.event.pull_request.merged == true || github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: '18'
- run: npm install
- name: cdk diff
uses: youyo/aws-cdk-github-actions@v2
with:
cdk_subcommand: 'diff'
actions_comment: true
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: cdk deploy
uses: youyo/aws-cdk-github-actions@v2
with:
cdk_subcommand: 'deploy'
cdk_stack: '*'
cdk_args: '--require-approval never'
actions_comment: false
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment