Skip to content

Merge pull request #1 from West-Michigan-AWS-Users-Group/add-cdk-depl… #1

Merge pull request #1 from West-Michigan-AWS-Users-Group/add-cdk-depl…

Merge pull request #1 from West-Michigan-AWS-Users-Group/add-cdk-depl… #1

Workflow file for this run

on:
push:
branches:
- develop
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Install Python dependencies and CDK
run: |
# install your Python dependencies here
npm install -g aws-cdk
python -m pip install --use-feature=fast-deps --upgrade pip
pip install -r cdk/requirements.txt
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@master
with:
aws-access-key-id: ${{ secrets.SA_CDK_DEPLOYUSER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SA_CDK_DEPLOYUSER_AWS_SECRET_ACCESS_KEY }}
aws-region: "us-west-2"
- name: Set Environment Name
run: |
if [ "$GITHUB_REF" == "refs/heads/develop" ]; then
AWS_ENV="devA"
elif [ "$GITHUB_REF" == "refs/heads/main" ]; then
AWS_ENV="productionA"
else
echo "Skipping workflow for branch $GITHUB_REF"
exit 0
fi
echo "Setting stack name to $AWS_ENV"
echo "AWS_ENV=$AWS_ENV" >> $GITHUB_ENV
- name: CDK synth
if: ${{ env.AWS_ENV == 'devA' || env.AWS_ENV == 'productionA' }}
run: npx cdk synth ${{ env.AWS_ENV }} --require-approval=never
- name: CDK diff
if: ${{ env.AWS_ENV == 'devA' || env.AWS_ENV == 'productionA' }}
run: npx cdk diff ${{ env.AWS_ENV }} --require-approval=never
- name: CDK cdk deploy
if: ${{ env.AWS_ENV == 'devA' || env.AWS_ENV == 'productionA' }}
run: npx cdk deploy ${{ env.AWS_ENV }} --require-approval=never --all