Skip to content

Commit b89268c

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

File tree

6 files changed

+116
-13
lines changed

6 files changed

+116
-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: Configure AWS Credentials
19+
uses: aws-actions/configure-aws-credentials@v4
20+
with:
21+
aws-region: eu-west-2
22+
role-to-assume: ${{ inputs.aws-role-arn }}
23+
24+
- name: Node setup
25+
uses: ./.github/actions/node-setup
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: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,8 @@ 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'
22-
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
18+
- name: Python setup
19+
uses: ./.github/actions/python-setup
3120

3221
- name: Check Workflows
3322
run: uvx zizmor --format sarif . > zizmor-results.sarif

.github/workflows/cdk-synth.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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 (Dev)
16+
runs-on: ubuntu-22.04
17+
environment: development
18+
19+
steps:
20+
- name: Check out repository
21+
uses: actions/checkout@v4
22+
with:
23+
persist-credentials: false
24+
25+
26+
- name: CDK Synth Dev
27+
uses: ./.github/actions/cdk-synth
28+
with:
29+
dc-environment: ${{ vars.DC_ENVIRONMENT }}
30+
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)