feat(ci): synth-per-variant build with github:* context in artifact#91
Merged
Conversation
krokoko
reviewed
May 14, 2026
mayakost
previously approved these changes
May 14, 2026
Add matrix strategy (agentcore variant) to build job. After the full mise build, synthesize CDK output per variant and upload as immutable artifact for downstream deploy workflow consumption. Refs: #73 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The .gitignore already excludes /cdk/cdk-*.out/, so git add . never stages synth output — the pathspec exclusion was belt-and- suspenders with no effect. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Removed retention days for uploaded artifacts in build workflow.
…nth step Remove the separate `npx cdk synth` step — `mise run build` already runs `cdk synth -q` via the //cdk:build task chain. Upload the existing cdk/cdk.out/ directly as the variant artifact. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CDK reads CDK_CONTEXT_<key> env vars as context values, so setting
CDK_CONTEXT_computeVariant=${{ matrix.variant }} flows the variant
through mise run build → cdk synth without modifying mise tasks.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace CDK_CONTEXT env var with a cdk.context.json generation step that populates all 13 github:* tag values plus computeVariant and stackName. CDK reads cdk.context.json automatically during synth, so tags are baked into templates and carried in the artifact for deploy.yml to use without re-synthesis. Event-specific resolution normalizes github.sha/ref/head-ref across pull_request, merge_group, push, and workflow_dispatch triggers. All GitHub context is passed through env: variables to prevent script injection (CWE-78). Refs: #73 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
09e3fa0 to
5b5dbd5
Compare
CDK does not copy cdk.context.json into cdk.out/ during synthesis. Include it explicitly in the artifact so deploy.yml and release assets carry provenance of what context produced the templates. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
krokoko
approved these changes
May 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
strategy.matrixwithvariant: [agentcore]to the build jobcdk/cdk.context.jsonbefore build with all 13github:*tags,computeVariant, andstackName— CDK reads this automatically during synth, baking tags into CloudFormation templatespull_request,merge_group,push,workflow_dispatch) using intermediate env vars to prevent script injection (CWE-78)cdk/cdk.out/+cdk/cdk.context.jsonas immutable artifact (cdk-<variant>-out) for downstreamdeploy.yml/cdk/cdk-*.out/to.gitignoreHow it works
CDK's
Tags.of(stack).add()inmain.tscallsapp.node.tryGetContext('github:sha')etc. during synthesis. The values come fromcdk.context.json, so they are baked directly into the template's resourceTagsarrays. No context flags needed at deploy time.Context values generated
github:shagithub:refgithub:ref-typebranchbranchgithub:actorgithub.actorgithub.actorgithub.actorgithub:head-refgithub:base-refgithub:pr-numbergithub:run-idgithub.run_idgithub.run_idgithub.run_idgithub:run-attemptgithub.run_attemptgithub.run_attemptgithub.run_attemptgithub:eventgithub.event_namegithub.event_namegithub.event_namegithub:workflowgithub.workflowgithub.workflowgithub.workflowgithub:repositorygithub.repositorygithub.repositorygithub.repositorygithub:cleantruetruetrueLocal verification
Follow-ups
ecs,eks) added to matrix when compute paths are implementeddeploy.ymldownloads the artifact and runscdk deploy --app cdk.out— no re-synthesis neededTest plan
build (agentcore))cdk-agentcore-outartifact appears in workflow run (containscdk.out/+cdk.context.json)github:*tags baked into CloudFormation templateenv:+jq --arg)Refs: #73, #84, #93
🤖 Generated with Claude Code