Skip to content

feat(github): configurable build-deploy roles and separate MSBuild output paths - #48

Merged
ncipollina merged 2 commits into
mainfrom
feat/build-deploy-role-config-and-output-path
Oct 14, 2026
Merged

ncipollina merged 2 commits into
mainfrom
feat/build-deploy-role-config-and-output-path

Conversation

@ncipollina

@ncipollina ncipollina commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

#45: MSBuild OutputPath collision

build-deploy.yaml exposed its publish folder as an outputPath environment variable, both as a job-level env and through two $GITHUB_ENV writes. MSBuild reads environment variables as properties case-insensitively, so every project built into that folder.

  • Rename: the variable is now TEMPLATE_OUTPUT_PATH, matching pr-build.yaml (fix(github): stop pr-build redirecting MSBuild output and fix cdk-preview jq #44). Updated: the job env, both $GITHUB_ENV writes, and all 4 ${{ env.… }} references (Blazor publish, Lambda Native AOT action input, Lambda ZIP path, SPA copy).
  • Unchanged: the outputPath input and the composite action's outputPath input. The publish location is the same as before.
  • Regression guard: .github/scripts/check-msbuild-env.py, run by the new self-test, fails if any workflow or action exports an MSBuild output-path property (OutputPath, OutDir, BaseOutputPath, IntermediateOutputPath, PublishDir, …) through env: or $GITHUB_ENV.

#46: configurable deployment roles

The hard-coded arn:aws:iam::403542860824:role/github-deploy-role and us-east-1 are removed.

  • New inputs, named as in cdk-preview.yaml:
    • roleArn: development, non-tag runs
    • productionRoleArn: production, tag runs
    • awsRegion: default us-east-1
  • New composite action .github/actions/resolve-aws-deploy-role:
    • Runs as the first step when runCdk: true, so validation happens before anything is built and before credentials are requested.
    • Validates the region and the selected ARN.
    • Selects the role: refs/tags/* (which deploys <stackName>-prod) → productionRoleArn; all other runs → roleArn.
    • Errors name the input to fix.
  • Production safety: a tag run without productionRoleArn fails. There is no fallback to roleArn. A consumer that wants one role passes the same ARN to both inputs.
    • Reviewed against current consumers: all trigger build-deploy on push to main (development) or by workflow_dispatch. Production runs are dispatches on a tag (CloudTrail shows ref:refs/tags/* contexts), so explicit configuration is practical.
  • configure-aws-credentials is pinned to e1253824… (v6.3.0) as in cdk-preview.yaml, and now masks the account ID.
  • Unchanged: OIDC model, workflow permissions (id-token: write, contents: write for the existing release tagging), triggers, and every build, test, publish, deploy and tag step. No IAM roles, trust policies, accounts or permissions are changed.
  • Integration tests: they still run after development deployments with the roleArn credentials (never on tag runs), which is correct today but more permission than tests need. Separating them is tracked in [Feature]: Run build-deploy integration tests with a narrower role than the deployment role #47 and kept out of this PR.

Validation

Check Result
actionlint 1.7.12, build-deploy.yaml No new findings. The only addition is the $/… reference for the new action, the same known false positive as the existing Lambda action. The rest are pre-existing shellcheck notes also present on main
actionlint, self-test-build-deploy.yml clean
shellcheck, composite action script clean
MSBuild guard: this branch / main / v10.8 pass (0) / fail (3: build-deploy job env + 2 $GITHUB_ENV writes) / fail (5: also pr-build, fixed by #44)
Two-project .NET build with outputPath=<tmp>/publish in the environment (old behavior) both assemblies in publish/net10.0/, neither in its own bin (#45 reproduced)
Same build with TEMPLATE_OUTPUT_PATH=<tmp>/publish src/SelfTest.Library/bin/Release/net10.0/… and src/SelfTest.Second/bin/Release/net10.0/…; nothing in publish/
Role resolution: the action's script run locally against all 8 self-test cases 8/8 as expected
Self-test workflow on this PR the same 8 cases through the composite action, plus the MSBuild guard

The 8 role-resolution cases:

  • development selects roleArn, with or without productionRoleArn
  • a tag selects productionRoleArn
  • a tag without productionRoleArn fails (no fallback)
  • missing roleArn fails
  • malformed roleArn (shell metacharacters) fails
  • a productionRoleArn that is an IAM user ARN fails
  • a malformed region fails
  • failures never output a role

Codex review (P2, role paths): fixed in 37b6430. ARNs are validated by part:

  • partition aws, aws-cn or aws-us-gov
  • 12-digit account
  • an optional path of up to 512 printable non-space characters
  • a 1–64 character name

The same fix applies to cdk-preview.yaml's roleArn, which had the same limit. There are 5 new self-test cases (13 role-resolution cases in total, all passing on GitHub), and the same 13 cases were also run locally against cdk-preview's copy of the check, which agreed on every ARN.

Runner-level validation (throwaway branch, deleted; run 38502935434). This revision's build-deploy.yaml ran on a real runner through two paths that stop before any build, deploy or tag:

  • $/ resolution: the logs show $/ resolving to LayeredCraft/devops-templates/.github/actions/resolve-aws-deploy-role@<this revision>.
  • runCdk: true without roleArn: failed at step 2 with runCdk is true, but roleArn is not set…. All 27 later steps were skipped, including the CDK deploy and the tag step.
  • A non-existent role (arn:aws:iam::000000000000:role/…): the job logged Deploying development with the role from roleArn. and the selected role reached configure-aws-credentials, which AWS refused. The CDK deploy, integration tests and tag step were skipped.
  • Tags: the repository's tag count was unchanged (36).

No AWS deployment was made and no resource was touched to validate this. build-deploy.yaml itself is not run in CI because it deploys and pushes tags.

Compatibility and release

Part of the v11 migration. Recommended release: v11.1 (Release Drafter: type: feat → minor).

  • v11.0 was published as the breaking release and has not been adopted by any consumer. It left build-deploy.yaml unchanged from v10, so v11.1 completes the v11 migration for build-deploy rather than starting another major line.
  • Moving build-deploy from v10 with runCdk: true: callers pass roleArn, and productionRoleArn for tag runs. Callers with runCdk: false are unaffected. pr-build.yaml is unchanged. cdk-preview.yaml now also accepts IAM role paths (see the Codex fix below).
  • Consumers pinned to v10.x/v7.x are unaffected (verified): v7.2 → fc844c8, v10.7 → 1401b8f, v10.8 → 0ab844d, and v11.0 → 5b2db86 are unchanged, none contain this PR, and their build-deploy.yaml still has the old role. Nobody's reference is updated here: ncipollina/infrastructure, trivia-platform ×4, trivia-manager, lightsaber-skill, cosmere-tracker.

Migration for existing consumers

To keep exactly the v10 behavior:

    uses: LayeredCraft/devops-templates/.github/workflows/build-deploy.yaml@v11.1
    with:
      runCdk: true
      roleArn: arn:aws:iam::403542860824:role/github-deploy-role
      productionRoleArn: arn:aws:iam::403542860824:role/github-deploy-role
      awsRegion: us-east-1

Separate, narrowly trusted roles are preferred: development trust on ref:refs/heads/main, production on tags or a protected environment, exact repository_id, no pull_request, and no job_workflow_ref pinning. The README positions this in the v11 migration and documents the inputs, role selection, missing-configuration errors and migration.

Remaining risks and follow-ups

  • $/ composite action reference: actionlint doesn't recognize it, but it has now been exercised on a real runner (above). A cross-repository consumer run happens at first adoption of v11.1, the same mechanism the existing Lambda action already uses across repositories since v10.7.
  • Integration tests: they still run with the development deployment role until [Feature]: Run build-deploy integration tests with a narrower role than the deployment role #47.
  • Management-account role: the github-deploy-role trust (repo:ncipollina/*, AdministratorAccess) is unchanged and tracked separately where that role is defined.
  • Secrets: application-specific TMD_*/TMP_*/OPENAI_* secrets in build-deploy.yaml are untouched (out of scope).

Closes #45
Closes #46

🤖 Generated with Claude Code

@github-actions github-actions Bot added breaking-change Introduces a breaking change type: feat New feature labels Oct 14, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T02:36:05.829812Z 0387c9c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0387c9c4bd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…tput paths

Part of the v11 migration (released as v11.1).

Fix #45: build-deploy exported its publish folder as an `outputPath`
environment variable (job env and $GITHUB_ENV). MSBuild reads environment
variables as properties, so every project in a multi-project solution built
into that folder. The variable is now TEMPLATE_OUTPUT_PATH, matching
pr-build (#44); the publish location is unchanged. A self-test guard fails if
any workflow exports an MSBuild output-path property again.

Implement #46: build-deploy no longer hard-codes the management-account role
and region. Callers pass roleArn (development, non-tag runs) and
productionRoleArn (production, tag runs), plus awsRegion (default
us-east-1). A composite action validates them and selects the role before
the build and before any credentials are requested; tag runs require
productionRoleArn and never fall back to roleArn. configure-aws-credentials
is pinned to a commit and masks the account ID. No IAM, trust, or
permission changes.

Callers moving build-deploy from v10 with runCdk: true pass roleArn and,
for tag runs, productionRoleArn; to keep the v10 behavior, pass
arn:aws:iam::403542860824:role/github-deploy-role for both and
awsRegion: us-east-1. Callers pinned to v10.x are unaffected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ncipollina
ncipollina force-pushed the feat/build-deploy-role-config-and-output-path branch from 0387c9c to 9897863 Compare October 14, 2026 02:36
@ncipollina ncipollina changed the title feat(github)!: configurable build-deploy roles and separate MSBuild output paths feat(github): configurable build-deploy roles and separate MSBuild output paths Oct 14, 2026
@ncipollina ncipollina removed the breaking-change Introduces a breaking change label Oct 14, 2026
The role-ARN check limited everything after `role/` to 64 characters, which
rejected valid roles with a path (IAM allows a path of up to 512 characters
plus a 64-character name) and path punctuation. Validate the partition,
account, path, and name separately in resolve-aws-deploy-role and
cdk-preview, and add self-test cases for path roles and the limits.

Addresses Codex review feedback on #48.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ncipollina
ncipollina merged commit b342def into main Oct 14, 2026
21 checks passed
@ncipollina
ncipollina deleted the feat/build-deploy-role-config-and-output-path branch October 14, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feat New feature

Projects

None yet

1 participant