Skip to content

wip: feat: add resolve-stack-config and integrate with terraform-deploy - #262

Draft
stekern wants to merge 5 commits into
mainfrom
feat/resolve-stack-config
Draft

wip: feat: add resolve-stack-config and integrate with terraform-deploy#262
stekern wants to merge 5 commits into
mainfrom
feat/resolve-stack-config

Conversation

@stekern

@stekern stekern commented May 15, 2026

Copy link
Copy Markdown
Member

Warning

Do not merge as-is. Before merging, the terraform-deploy changes need to be removed from this PR — see "Planned rollout" below.

Summary

  • New composite action resolve-stack-config — takes a JSON array of { pattern, envVars } blocks plus a stack-dir, and emits a sourceable env file when a pattern matches. First-match-wins. Empty / non-matching input is a fast no-op (the resolve step is skipped, no Python runs, no file is created).
  • Enrolled with release-please and the release workflow's path filter, mirroring the pattern used for evaluate-automerge in feat: add evaluate-automerge composite action #215 + 6732049.
  • CI: unit tests covering matching, schema validation, key/value validation, shell-injection round-trip, file permissions, and forward-compat for unknown block keys.

The PR currently also touches terraform-deploy and adds an integration e2e job, but those changes are slated to be split out (see below).

Planned rollout

  1. Drop the terraform-deploy changes (terraform-deploy/action.yml modifications, the test-e2e-terraform-deploy-stack-config CI job, and any related commits) from this PR.
  2. Merge this PR. release-please opens a release PR for resolve-stack-config. Merge that to produce the first resolve-stack-config-vX.Y.Z tag and SHA.
  3. Follow-up PR updates terraform-deploy to take a stack-config input and references oslokommune/composite-actions/resolve-stack-config@<sha> with the tag SHA. Adds the integration e2e job at that point.

This avoids landing terraform-deploy with a temporary local-path reference, and keeps the audit trail clean (one PR per enrolled action, one PR per terraform-deploy change).

Test plan

  • test-resolve-stack-config job passes (unit tests).
  • Existing CI jobs are unaffected once terraform-deploy changes are removed.

Introduces a new composite action `resolve-stack-config` that takes a JSON
array of `{pattern, envVars}` blocks plus a stack-dir, and emits a sourceable
env file when a pattern matches. `terraform-deploy` gains a `stack-config`
input and sources the resulting file before `terraform apply`, letting
callers inject provider-specific env vars (e.g., `TF_VAR_*`) on a per-stack
basis without provider-specific code in the action.

CI:
- Unit tests for resolve-stack-config (matching, schema validation,
  shell-injection round-trip, file permissions, forward-compat).
- E2E through terraform-deploy: deploys two stacks, asserts that a
  matching pattern injects a TF_VAR that reaches the Terraform output,
  and that a non-matching pattern leaves the variable's default in place.

terraform-deploy currently references resolve-stack-config via a local path
so the integration can be tested in this repo's CI. Before tagging a release
the path must be swapped for a SHA-pinned URL — see TODO in
terraform-deploy/action.yml.
@stekern
stekern requested a review from a team as a code owner May 15, 2026 13:45
@stekern stekern changed the title feat: add resolve-stack-config and integrate with terraform-deploy wip: feat: add resolve-stack-config and integrate with terraform-deploy May 15, 2026
@stekern
stekern marked this pull request as draft May 15, 2026 13:45
stekern added 4 commits May 15, 2026 15:46
…flow

- Add resolve-stack-config to release-please-config.json packages
- Add resolve-stack-config to .release-please-manifest.json at 0.0.0
  (next feat commit will bump it to 0.1.0)
- Add resolve-stack-config/* to the release workflow's path filter so
  changes to this action trigger a release-please run

Mirrors the enrollment used for evaluate-automerge in 6732049 + e58cc1c.
…tern

`PurePosixPath.full_match("X/**")` requires at least one path segment
after `**`, so a flat stack-dir like `stack-match` did not match the
pattern `stack-match/**`. Switch to nested layout (`stacks/dev/app-match`)
which matches `stacks/dev/**`, mirroring realistic stack layouts where
stacks always live below `<env>/`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant