Skip to content

Commit a8a1e1d

Browse files
committed
WIP
1 parent 6808f17 commit a8a1e1d

File tree

6 files changed

+123
-17
lines changed

6 files changed

+123
-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 Deploy
28+
run: scripts/cdk-deploy --all --concurrency 3 --require-approval never --asset-parallelism true
29+
shell: bash
30+
env:
31+
DC_ENVIRONMENT: ${{ inputs.dc-environment }}

.github/actions/cdk-synth/action.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,22 @@ runs:
1818
- name: Node setup
1919
uses: ./.github/actions/node-setup
2020

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 }}
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 }}
2626

2727
- name: CDK Synth
2828
run: scripts/cdk-synth --all
2929
shell: bash
3030
env:
3131
DC_ENVIRONMENT: ${{ inputs.dc-environment }}
32+
33+
# ToDo: This produces changes on CI, but not when run locally.
34+
# - name: Check Diagram
35+
# shell: bash
36+
# run: |
37+
# sudo apt install -y graphviz
38+
# uv run make_graph.py
39+
# git diff --exit-code || (echo "Please update graph and commit changes." && exit 1)

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: Build and Test
22

3-
on:
4-
push:
5-
branches: [github-actions-deploy]
6-
3+
on: push
74

85
jobs:
96
build-and-test:
@@ -32,8 +29,3 @@ jobs:
3229

3330
- name: Pre-test checks
3431
run: uv run scripts/code-check
35-
36-
# ToDo a check for whether the graph needs to be updated.
37-
# Install graphviz
38-
# uv run make_graph.py
39-
# git diff --exit-code || (echo "Please update graph and commit changes." && exit 1)

.github/workflows/cdk-deploy.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: CDK Deploy
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-deploy-development:
15+
name: CDK Deploy (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 Deploy Development
23+
uses: ./.github/actions/cdk-deploy
24+
with:
25+
dc-environment: ${{ vars.DC_ENVIRONMENT }}
26+
aws-role-arn: ${{ secrets.AWS_ROLE_ARN }}
27+
28+
cdk-deploy-staging:
29+
name: CDK Deploy (Staging)
30+
if: ${{ github.ref == 'refs/heads/github-actions-deploy' }} # ToDo: Change to main
31+
needs: cdk-deploy-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 Deploy Staging
39+
uses: ./.github/actions/cdk-deploy
40+
with:
41+
dc-environment: ${{ vars.DC_ENVIRONMENT }}
42+
aws-role-arn: ${{ secrets.AWS_ROLE_ARN }}
43+
44+
cdk-deploy-production:
45+
name: CDK Deploy (Production)
46+
if: ${{ github.ref == 'refs/heads/main' }}
47+
needs: cdk-deploy-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 Deploy Production
55+
uses: ./.github/actions/cdk-deploy
56+
with:
57+
dc-environment: ${{ vars.DC_ENVIRONMENT }}
58+
aws-role-arn: ${{ secrets.AWS_ROLE_ARN }}

scripts/cdk-deploy

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

scripts/cdk-synth

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ set -euxo pipefail
33

44
# Echo environment information
55
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
96

107
# Check if CDK is available in node_modules
118
if [ -f "./node_modules/.bin/cdk" ]; then

0 commit comments

Comments
 (0)