Skip to content

Commit 6d069ab

Browse files
committed
chore: create PR with layer arn updates
Signed-off-by: heitorlessa <[email protected]>
1 parent 589d30e commit 6d069ab

File tree

2 files changed

+52
-11
lines changed

2 files changed

+52
-11
lines changed

.github/workflows/publish_v2_layer.yml

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ on:
2626
jobs:
2727
build-layer:
2828
permissions:
29+
# lower privilege propagated from parent workflow (release.yml)
2930
contents: read
3031
id-token: none
3132
pages: none
@@ -88,9 +89,7 @@ jobs:
8889
# lower privilege propagated from parent workflow (release.yml)
8990
permissions:
9091
id-token: write
91-
contents: write
92-
pull-requests: write
93-
pages: write
92+
contents: read
9493
uses: ./.github/workflows/reusable_deploy_v2_layer_stack.yml
9594
secrets: inherit
9695
with:
@@ -104,9 +103,7 @@ jobs:
104103
# lower privilege propagated from parent workflow (release.yml)
105104
permissions:
106105
id-token: write
107-
contents: write
108-
pull-requests: write
109-
pages: write
106+
contents: read
110107
uses: ./.github/workflows/reusable_deploy_v2_layer_stack.yml
111108
secrets: inherit
112109
with:
@@ -147,6 +144,50 @@ jobs:
147144
environment: "layer-prod"
148145
package-version: ${{ inputs.latest_published_version }}
149146

147+
# Updating the documentation with the latest Layer ARNs is a two-phase process
148+
#
149+
# 1. Update layer ARNs with latest deployed locally and create a PR with these changes
150+
# 2. Pull from temporary branch with these changes and update the docs we're releasing
151+
#
152+
# This keeps our permissions tight and we don't run into a conflict,
153+
# where a new release creates a new doc (2.16.0) while layers are still pointing to 2.15
154+
# because the PR has to be merged while release process is running
155+
156+
update_v2_layer_arn_docs:
157+
needs: prod
158+
outputs:
159+
temp_branch: ${{ steps.create-pr.outputs.temp_branch }}
160+
runs-on: ubuntu-latest
161+
permissions:
162+
# lower privilege propagated from parent workflow (release.yml)
163+
contents: write
164+
pull-requests: write
165+
id-token: none
166+
pages: none
167+
steps:
168+
- name: Checkout repository # reusable workflows start clean, so we need to checkout again
169+
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
170+
with:
171+
fetch-depth: 0
172+
- name: Download CDK layer artifact
173+
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
174+
with:
175+
name: cdk-layer-stack
176+
path: cdk-layer-stack/
177+
- name: Replace layer versions in documentation
178+
run: |
179+
ls -la cdk-layer-stack/
180+
./layer/scripts/update_layer_arn.sh cdk-layer-stack
181+
- name: Create PR
182+
id: create-pr
183+
uses: ./.github/actions/create-pr
184+
with:
185+
files: "docs/index.md examples"
186+
temp_branch_prefix: "ci-layer-docs"
187+
pull_request_title: "chore(ci): layer docs update"
188+
github_token: ${{ secrets.GITHUB_TOKEN }}
189+
190+
150191
prepare_docs_alias:
151192
runs-on: ubuntu-latest
152193
permissions:
@@ -167,16 +208,16 @@ jobs:
167208
fi
168209
echo DOCS_ALIAS="$DOCS_ALIAS" >> "$GITHUB_OUTPUT"
169210
170-
release-docs:
171-
needs: [prod, prepare_docs_alias]
211+
release_docs:
212+
needs: [update_v2_layer_arn_docs, prepare_docs_alias]
172213
permissions:
173214
# lower privilege propagated from parent workflow (release.yml)
174215
contents: write
175216
pages: write
176-
id-token: write
177217
pull-requests: none
218+
id-token: none
178219
uses: ./.github/workflows/reusable_publish_docs.yml
179220
with:
180221
version: ${{ inputs.latest_published_version }}
181222
alias: ${{ needs.prepare_docs_alias.outputs.DOCS_ALIAS }}
182-
detached_mode: true
223+
git_ref: ${{ needs.update_v2_layer_arn_docs.outputs.temp_branch }}

layer/scripts/update_layer_arn.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# This script is run during the reusable_update_v2_layer_arn_docs CI job,
3+
# This script is run during the publish_v2_layer.yml CI job,
44
# and it is responsible for replacing the layer ARN in our documentation,
55
# based on the output files generated by CDK when deploying to each pseudo_region.
66
#

0 commit comments

Comments
 (0)