Skip to content

Commit 18bee37

Browse files
docs(homepage): auto-update Layer ARN on every release (#1610)
Co-authored-by: Heitor Lessa <[email protected]>
1 parent e5a263a commit 18bee37

File tree

7 files changed

+467
-154
lines changed

7 files changed

+467
-154
lines changed

.github/workflows/publish_v2_layer.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ jobs:
8282
stage: "BETA"
8383
artefact-name: "cdk-layer-artefact"
8484
environment: "layer-beta"
85+
latest_published_version: ${{ inputs.latest_published_version }}
8586

8687
# deploy-prod:
8788
# needs:
@@ -92,6 +93,7 @@ jobs:
9293
# stage: "PROD"
9394
# artefact-name: "cdk-layer-artefact"
9495
# environment: "layer-prod"
96+
# latest_published_version: ${{ inputs.latest_published_version }}
9597

9698
deploy-sar-beta:
9799
needs: build-layer
@@ -104,7 +106,7 @@ jobs:
104106
package-version: ${{ needs.build-layer.outputs.release-tag-version }}
105107

106108
deploy-sar-prod:
107-
needs: deploy-sar-beta
109+
needs: [build-layer, deploy-sar-beta]
108110
uses: ./.github/workflows/reusable_deploy_v2_sar.yml
109111
secrets: inherit
110112
with:

.github/workflows/reusable_deploy_v2_layer_stack.yml

+22-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ on:
2222
description: "GitHub Environment to use for encrypted secrets"
2323
required: true
2424
type: string
25+
latest_published_version:
26+
description: "Latest version that is published"
27+
required: true
28+
type: string
2529

2630
jobs:
2731
deploy-cdk-stack:
@@ -97,6 +101,23 @@ jobs:
97101
- name: unzip artefact
98102
run: unzip cdk.out.zip
99103
- name: CDK Deploy Layer
100-
run: cdk deploy --app cdk.out --context region=${{ matrix.region }} 'LayerV2Stack' --require-approval never --verbose
104+
run: cdk deploy --app cdk.out --context region=${{ matrix.region }} 'LayerV2Stack' --require-approval never --verbose --outputs-file cdk-outputs.json
105+
- name: Store latest Layer ARN
106+
if: ${{ inputs.stage == 'PROD' }}
107+
run: |
108+
jq -c '.LayerV2Stack.VersionArn' cdk-outputs.json > cdk-layer-stack-${{ matrix.region }}-layer-version.txt
109+
jq -c '.LayerV2Stack.Arm64VersionArn' cdk-outputs.json >> cdk-layer-stack-${{ matrix.region }}-layer-version.txt
101110
- name: CDK Deploy Canary
102111
run: cdk deploy --app cdk.out --context region=${{ matrix.region}} --parameters DeployStage="${{ inputs.stage }}" 'CanaryV2Stack' --require-approval never --verbose
112+
- name: Save Layer ARN artifact
113+
uses: actions/upload-artifacts@v3
114+
with:
115+
name: cdk-layer-stack
116+
path: cdk-layer-stack*
117+
118+
update_v2_layer_arn_docs:
119+
permissions:
120+
contents: write
121+
uses: ./.github/workflows/reusable_update_v2_layer_arn_docs.yml
122+
with:
123+
latest_published_version: ${{ inputs.latest_published_version }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Update V2 Layer ARN Docs
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
latest_published_version:
7+
description: "Latest PyPi published version to rebuild latest docs for, e.g. v2.0.0"
8+
type: string
9+
required: true
10+
11+
permissions:
12+
contents: write
13+
14+
env:
15+
BRANCH: v2
16+
17+
jobs:
18+
publish_v2_layer_arn:
19+
# Force Github action to run only a single job at a time (based on the group name)
20+
# This is to prevent race-condition and inconsistencies with changelog push
21+
concurrency:
22+
group: changelog-build
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout repository # reusable workflows start clean, so we need to checkout again
26+
uses: actions/checkout@v3
27+
with:
28+
fetch-depth: 0
29+
- name: Git client setup and refresh tip
30+
run: |
31+
git config user.name "Release bot"
32+
git config user.email "[email protected]"
33+
git config pull.rebase true
34+
git config remote.origin.url >&- || git remote add origin https://github.com/"${origin}" # Git Detached mode (release notes) doesn't have origin
35+
git pull origin "${BRANCH}"
36+
- name: Download CDK layer artifact
37+
uses: actions/download-artifact@v3
38+
with:
39+
name: cdk-layer-stack
40+
path: cdk-layer-stack
41+
- name: Replace layer versions in documentation
42+
run: ./layer/scripts/update_layer_arn.sh cdk-layer-stack
43+
- name: Update documentation in trunk
44+
run: |
45+
HAS_CHANGE=$(git status --porcelain)
46+
test -z "${HAS_CHANGE}" && echo "Nothing to update" && exit 0
47+
git add docs/index.md
48+
git commit -m "chore: update v2 layer ARN on documentation"
49+
git pull origin "${BRANCH}" # prevents concurrent branch update failing push
50+
git push origin HEAD:refs/heads/"${BRANCH}"
51+
52+
release-docs:
53+
needs: publish_v2_layer_arn
54+
permissions:
55+
contents: write
56+
pages: write
57+
uses: ./.github/workflows/reusable_publish_docs.yml
58+
with:
59+
version: ${{ inputs.latest_published_version }}
60+
alias: latest

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ repos:
4040
- id: cfn-python-lint
4141
files: examples/.*\.(yaml|yml)$
4242
- repo: https://github.com/rhysd/actionlint
43-
rev: v1.6.16
43+
rev: v1.6.21
4444
hooks:
4545
- id: actionlint-docker
4646
args: [-pyflakes=]

0 commit comments

Comments
 (0)