Skip to content

Commit c40d17f

Browse files
committed
feat(layers): add initial support for publishing v2 beta layer
1 parent 5046a35 commit c40d17f

File tree

2 files changed

+185
-0
lines changed

2 files changed

+185
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Deploy v2 layer to all regions
2+
3+
permissions:
4+
id-token: write
5+
contents: read
6+
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
latest_published_version:
11+
description: "Latest PyPi published version to rebuild latest docs for, e.g. v1.22.0"
12+
default: "v1.22.0"
13+
required: true
14+
# workflow_run:
15+
# workflows: ["Publish to PyPi"]
16+
# types:
17+
# - completed
18+
19+
jobs:
20+
build-layer:
21+
runs-on: ubuntu-latest
22+
if: ${{ (github.event.workflow_run.conclusion == 'success') || (github.event_name == 'workflow_dispatch') }}
23+
defaults:
24+
run:
25+
working-directory: ./layer
26+
steps:
27+
- name: checkout
28+
uses: actions/checkout@v3
29+
with:
30+
fetch-depth: 0
31+
- name: Install poetry
32+
run: pipx install poetry
33+
- name: Setup Node.js
34+
uses: actions/setup-node@v3
35+
with:
36+
node-version: "16.12"
37+
- name: Setup python
38+
uses: actions/setup-python@v4
39+
with:
40+
python-version: "3.9"
41+
cache: "pip"
42+
- name: Resolve and install project dependencies
43+
# CDK spawns system python when compiling stack
44+
# therefore it ignores both activated virtual env and cached interpreter by GH
45+
run: |
46+
poetry export --format requirements.txt --output requirements.txt
47+
pip install -r requirements.txt
48+
- name: Set release notes tag
49+
run: |
50+
RELEASE_INPUT=${{ inputs.latest_published_version }}
51+
LATEST_TAG=$(git describe --tag --abbrev=0)
52+
RELEASE_TAG_VERSION=${RELEASE_INPUT:-$LATEST_TAG}
53+
echo RELEASE_TAG_VERSION="${RELEASE_TAG_VERSION:1}" >> "$GITHUB_ENV"
54+
- name: install cdk and deps
55+
run: |
56+
npm install -g aws-cdk@2.29.0
57+
cdk --version
58+
- name: CDK build
59+
run: cdk synth --context version="$RELEASE_TAG_VERSION" -o cdk.out
60+
- name: zip output
61+
run: zip -r cdk.out.zip cdk.out
62+
- name: Archive CDK artifacts
63+
uses: actions/upload-artifact@v3
64+
with:
65+
name: cdk-layer-artefact
66+
path: layer/cdk.out.zip
67+
68+
deploy-beta:
69+
needs:
70+
- build-layer
71+
uses: ./.github/workflows/reusable_deploy_v2_layer_stack.yml
72+
secrets: inherit
73+
with:
74+
stage: "BETA"
75+
artefact-name: "cdk-layer-artefact"
76+
environment: "layer-beta"
77+
78+
# deploy-prod:
79+
# needs:
80+
# - deploy-beta
81+
# uses: ./.github/workflows/reusable_deploy_layer_stack.yml
82+
# secrets: inherit
83+
# with:
84+
# stage: "PROD"
85+
# artefact-name: "cdk-layer-artefact"
86+
# environment: "layer-prod"
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Deploy CDK Layer v2 stack
2+
3+
permissions:
4+
id-token: write
5+
contents: read
6+
7+
on:
8+
workflow_call:
9+
inputs:
10+
stage:
11+
description: "Deployment stage (BETA, PROD)"
12+
required: true
13+
type: string
14+
artefact-name:
15+
description: "CDK Layer Artefact name to download"
16+
required: true
17+
type: string
18+
environment:
19+
description: "GitHub Environment to use for encrypted secrets"
20+
required: true
21+
type: string
22+
23+
jobs:
24+
deploy-cdk-stack:
25+
runs-on: ubuntu-latest
26+
environment: ${{ inputs.environment }}
27+
defaults:
28+
run:
29+
working-directory: ./layer
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
region:
34+
[
35+
"af-south-1",
36+
"eu-central-1",
37+
"us-east-1",
38+
"us-east-2",
39+
"us-west-1",
40+
"us-west-2",
41+
"ap-east-1",
42+
"ap-south-1",
43+
"ap-northeast-1",
44+
"ap-northeast-2",
45+
"ap-southeast-1",
46+
"ap-southeast-2",
47+
"ca-central-1",
48+
"eu-west-1",
49+
"eu-west-2",
50+
"eu-west-3",
51+
"eu-south-1",
52+
"eu-north-1",
53+
"sa-east-1",
54+
"ap-southeast-3",
55+
"ap-northeast-3",
56+
"me-south-1",
57+
]
58+
steps:
59+
- name: checkout
60+
uses: actions/checkout@v3
61+
- name: Install poetry
62+
run: pipx install poetry
63+
- name: aws credentials
64+
uses: aws-actions/configure-aws-credentials@v1
65+
with:
66+
aws-region: ${{ matrix.region }}
67+
role-to-assume: ${{ secrets.AWS_LAYERS_ROLE_ARN }}
68+
- name: Setup Node.js
69+
uses: actions/setup-node@v3
70+
with:
71+
node-version: "16.12"
72+
- name: Setup python
73+
uses: actions/setup-python@v4
74+
with:
75+
python-version: "3.9"
76+
cache: "pip"
77+
- name: Resolve and install project dependencies
78+
# CDK spawns system python when compiling stack
79+
# therefore it ignores both activated virtual env and cached interpreter by GH
80+
run: |
81+
poetry export --format requirements.txt --output requirements.txt
82+
pip install -r requirements.txt
83+
- name: install cdk and deps
84+
run: |
85+
npm install -g aws-cdk@2.29.0
86+
cdk --version
87+
- name: install deps
88+
run: poetry install
89+
- name: Download artifact
90+
uses: actions/download-artifact@v3
91+
with:
92+
name: ${{ inputs.artefact-name }}
93+
path: layer
94+
- name: unzip artefact
95+
run: unzip cdk.out.zip
96+
- name: CDK Deploy Layer
97+
run: cdk deploy --app cdk.out --context region=${{ matrix.region }} 'LayerStack' --require-approval never --verbose
98+
- name: CDK Deploy Canary
99+
run: cdk deploy --app cdk.out --context region=${{ matrix.region}} --parameters DeployStage="${{ inputs.stage }}" 'CanaryStack' --require-approval never --verbose

0 commit comments

Comments
 (0)