Skip to content

Commit 40e0711

Browse files
committed
WiP CDK synth workflow
1 parent 4fbbe65 commit 40e0711

File tree

6 files changed

+140
-13
lines changed

6 files changed

+140
-13
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: 'CDK Synth'
2+
description: 'Check CDK output is valid'
3+
inputs:
4+
dc-environment:
5+
description: 'Environment to deploy to (development, staging, production)'
6+
required: true
7+
aws-role-arn:
8+
description: 'ARN of AWS account to assume'
9+
required: true
10+
11+
runs:
12+
using: composite
13+
steps:
14+
15+
- name: Python setup
16+
uses: ./.github/actions/python-setup
17+
18+
- name: Node setup
19+
uses: ./.github/actions/node-setup
20+
21+
- name: Configure AWS Credentials
22+
uses: aws-actions/configure-aws-credentials@v4
23+
with:
24+
aws-region: eu-west-2
25+
role-to-assume: ${{ inputs.aws-role-arn }}
26+
27+
- name: CDK Synth
28+
run: scripts/cdk-synth --all
29+
shell: bash
30+
env:
31+
DC_ENVIRONMENT: ${{ inputs.dc-environment }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: 'Node Setup'
2+
description: 'Install node/npm and dependencies'
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Install node
8+
uses: actions/setup-node@v4
9+
with:
10+
node-version: "18"
11+
cache: 'npm'
12+
13+
- name: Install node modules
14+
run: npm ci
15+
shell: bash
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: 'Python Setup'
2+
description: 'Install uv, python and dependencies'
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Install python
8+
uses: actions/setup-python@v5
9+
10+
- name: Install uv
11+
uses: astral-sh/setup-uv@v5
12+
with:
13+
enable-cache: true
14+
cache-suffix: "uv-cache-v1"
15+
cache-dependency-glob: |
16+
**/uv.lock
17+
**/pyproject.toml
18+
19+
- name: Create venv
20+
run: uv sync
21+
shell: bash

.github/workflows/build-and-test.yml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,11 @@ jobs:
1515
with:
1616
persist-credentials: false
1717

18-
- name: Install python
19-
uses: actions/setup-python@v5
20-
with:
21-
python-version: '3.12'
18+
- name: Python setup
19+
uses: ./.github/actions/python-setup
2220

23-
- name: Install uv
24-
uses: astral-sh/setup-uv@v5
25-
with:
26-
enable-cache: true
27-
cache-suffix: "uv-cache-v1"
28-
cache-dependency-glob: |
29-
**/uv.lock
30-
**/pyproject.toml
21+
- name: Node setup
22+
uses: ./.github/actions/node-setup
3123

3224
- name: Check Workflows
3325
run: uvx zizmor --format sarif . > zizmor-results.sarif
@@ -40,7 +32,6 @@ jobs:
4032
# sarif_file: zizmor-results.sarif
4133
# category: zizmor
4234

43-
4435
- name: Pre-test checks
4536
run: uv run scripts/code-check
4637

.github/workflows/cdk-synth.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: CDK Synth
2+
3+
on:
4+
# workflow_run:
5+
# workflows: ["Build and Test"]
6+
# types: [completed]
7+
push:
8+
branches: [github-actions-deploy]
9+
10+
permissions:
11+
id-token: write
12+
13+
jobs:
14+
cdk-synth-development:
15+
name: CDK Synth (Development)
16+
runs-on: ubuntu-22.04
17+
environment: development
18+
steps:
19+
- name: Check out repository
20+
uses: actions/checkout@v4
21+
22+
- name: CDK Synth Development
23+
uses: ./.github/actions/cdk-synth
24+
with:
25+
dc-environment: ${{ vars.DC_ENVIRONMENT }}
26+
aws-role-arn: ${{ secrets.AWS_ROLE_ARN }}
27+
28+
cdk-synth-staging:
29+
name: CDK Synth (Staging)
30+
if: ${{ github.ref == 'refs/heads/github-actions-deploy' }} # ToDo: Change to main
31+
needs: cdk-synth-development
32+
runs-on: ubuntu-22.04
33+
environment: staging
34+
steps:
35+
- name: CDK Synth Staging
36+
uses: ./.github/actions/cdk-synth
37+
with:
38+
dc-environment: ${{ vars.DC_ENVIRONMENT }}
39+
aws-role-arn: ${{ secrets.AWS_ROLE_ARN }}
40+
41+
cdk-synth-production:
42+
name: CDK Synth (Production)
43+
if: ${{ github.ref == 'refs/heads/main' }}
44+
needs: cdk-synth-staging
45+
runs-on: ubuntu-22.04
46+
environment: production
47+
steps:
48+
- name: CDK Synth Production
49+
uses: ./.github/actions/cdk-synth
50+
with:
51+
dc-environment: ${{ vars.DC_ENVIRONMENT }}
52+
aws-role-arn: ${{ secrets.AWS_ROLE_ARN }}

scripts/cdk-synth

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
4+
# Echo environment information
5+
echo "Running CDK synth with DC_ENVIRONMENT=$DC_ENVIRONMENT"
6+
if [ -n "${AWS_PROFILE+x}" ]; then
7+
echo "Using AWS_PROFILE=$AWS_PROFILE"
8+
fi
9+
10+
# Check if CDK is available in node_modules
11+
if [ -f "./node_modules/.bin/cdk" ]; then
12+
echo "Using CDK from node_modules"
13+
uv run ./node_modules/.bin/cdk synth "$@"
14+
else
15+
echo "Error: CDK not found in node_modules. Make sure it's installed with 'npm ci'"
16+
exit 1
17+
fi

0 commit comments

Comments
 (0)