Skip to content

Commit 6808f17

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

File tree

6 files changed

+148
-17
lines changed

6 files changed

+148
-17
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: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,12 @@ jobs:
1212
steps:
1313
- name: Check out repository
1414
uses: actions/checkout@v4
15-
with:
16-
persist-credentials: false
17-
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
15+
16+
- name: Python setup
17+
uses: ./.github/actions/python-setup
18+
19+
- name: Node setup
20+
uses: ./.github/actions/node-setup
3121

3222
- name: Check Workflows
3323
run: uvx zizmor --format sarif . > zizmor-results.sarif
@@ -40,7 +30,6 @@ jobs:
4030
# sarif_file: zizmor-results.sarif
4131
# category: zizmor
4232

43-
4433
- name: Pre-test checks
4534
run: uv run scripts/code-check
4635

.github/workflows/cdk-synth.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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: Check out repository
36+
uses: actions/checkout@v4
37+
38+
- name: CDK Synth Staging
39+
uses: ./.github/actions/cdk-synth
40+
with:
41+
dc-environment: ${{ vars.DC_ENVIRONMENT }}
42+
aws-role-arn: ${{ secrets.AWS_ROLE_ARN }}
43+
44+
cdk-synth-production:
45+
name: CDK Synth (Production)
46+
if: ${{ github.ref == 'refs/heads/main' }}
47+
needs: cdk-synth-staging
48+
runs-on: ubuntu-22.04
49+
environment: production
50+
steps:
51+
- name: Check out repository
52+
uses: actions/checkout@v4
53+
54+
- name: CDK Synth Production
55+
uses: ./.github/actions/cdk-synth
56+
with:
57+
dc-environment: ${{ vars.DC_ENVIRONMENT }}
58+
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)