Parent
Sub-issue of #73 (RFC: GitHub Actions CI/CD with protected deployment environment and approval gates)
Summary
Implement github:* resource tagging on all CDK stack resources via Tags.of(stack).add() in main.ts. Tags are injected through CDK context (-c) and default to sentinel none when not provided.
See tagging strategy addendum on #73: #73 (comment)
Scope
- Add
github:* tag resolution in cdk/src/main.ts (9 tags, all defaulting to none)
- Pass tags through CDK context values
- Add/update tests to verify tags are applied
- No CI/CD workflow changes — this is infrastructure-only
Tags
| Tag key |
Default |
$GITHUB_* variable |
gh CLI |
git CLI |
github:sha |
none |
$GITHUB_SHA |
gh api /repos/{owner}/{repo}/commits/{ref} --jq .sha |
git rev-parse HEAD |
github:ref |
none |
$GITHUB_REF_NAME |
gh api /repos/{owner}/{repo}/git/ref/heads/{branch} --jq .ref |
git branch --show-current |
github:ref-type |
none |
$GITHUB_REF_TYPE |
gh api /repos/{owner}/{repo}/git/ref/heads/{branch} → branch; /tags/{tag} → tag |
inferred from git describe --exact-match success/failure |
github:actor |
none |
$GITHUB_ACTOR |
gh api /user --jq .login |
git config user.name |
github:head-ref |
none |
$GITHUB_HEAD_REF |
gh pr view --json headRefName --jq .headRefName |
N/A (PR context only) |
github:run-id |
none |
$GITHUB_RUN_ID |
gh run list --limit 1 --json databaseId --jq '.[0].databaseId' |
N/A (CI only) |
github:event |
none |
$GITHUB_EVENT_NAME |
gh run view {run-id} --json event --jq .event |
N/A (CI only) |
github:repository |
none |
$GITHUB_REPOSITORY |
gh repo view --json nameWithOwner --jq .nameWithOwner |
git remote get-url origin | sed 's/.*github.com[:/]//' | sed 's/.git$//' |
github:clean |
none |
true (CI always clean) |
N/A |
[ -z "$(git status --porcelain)" ] && echo true || echo false |
Local deploy example
npx cdk deploy \
-c github:sha=$(git rev-parse HEAD) \
-c github:ref=$(git branch --show-current || echo detached) \
-c github:ref-type=branch \
-c github:actor=$(git config user.name) \
-c github:repository=$(gh repo view --json nameWithOwner --jq .nameWithOwner) \
-c github:clean=$([ -z "$(git status --porcelain)" ] && echo true || echo false)
CI deploy example (GitHub Actions)
- name: CDK Synth
run: |
npx cdk synth \
-c github:sha=${{ github.sha }} \
-c github:ref=${{ github.ref_name }} \
-c github:ref-type=${{ github.ref_type }} \
-c github:actor=${{ github.actor }} \
-c github:head-ref=${{ github.head_ref || '' }} \
-c github:run-id=${{ github.run_id }} \
-c github:event=${{ github.event_name }} \
-c github:repository=${{ github.repository }} \
-c github:clean=true
Acceptance criteria
Implementation
PR #85
Parent
Sub-issue of #73 (RFC: GitHub Actions CI/CD with protected deployment environment and approval gates)
Summary
Implement
github:*resource tagging on all CDK stack resources viaTags.of(stack).add()inmain.ts. Tags are injected through CDK context (-c) and default to sentinelnonewhen not provided.See tagging strategy addendum on #73: #73 (comment)
Scope
github:*tag resolution incdk/src/main.ts(9 tags, all defaulting tonone)Tags
$GITHUB_*variableghCLIgitCLIgithub:shanone$GITHUB_SHAgh api /repos/{owner}/{repo}/commits/{ref} --jq .shagit rev-parse HEADgithub:refnone$GITHUB_REF_NAMEgh api /repos/{owner}/{repo}/git/ref/heads/{branch} --jq .refgit branch --show-currentgithub:ref-typenone$GITHUB_REF_TYPEgh api /repos/{owner}/{repo}/git/ref/heads/{branch}→branch;/tags/{tag}→taggit describe --exact-matchsuccess/failuregithub:actornone$GITHUB_ACTORgh api /user --jq .logingit config user.namegithub:head-refnone$GITHUB_HEAD_REFgh pr view --json headRefName --jq .headRefNamegithub:run-idnone$GITHUB_RUN_IDgh run list --limit 1 --json databaseId --jq '.[0].databaseId'github:eventnone$GITHUB_EVENT_NAMEgh run view {run-id} --json event --jq .eventgithub:repositorynone$GITHUB_REPOSITORYgh repo view --json nameWithOwner --jq .nameWithOwnergit remote get-url origin | sed 's/.*github.com[:/]//' | sed 's/.git$//'github:cleannonetrue(CI always clean)[ -z "$(git status --porcelain)" ] && echo true || echo falseLocal deploy example
CI deploy example (GitHub Actions)
Acceptance criteria
noneImplementation
PR #85