Skip to content

Fix expand-terraform: use PR head branch for push#89

Merged
Alexanderamiri merged 1 commit into
mainfrom
fix/expand-tf-pr-branch-ref
Mar 17, 2026
Merged

Fix expand-terraform: use PR head branch for push#89
Alexanderamiri merged 1 commit into
mainfrom
fix/expand-tf-pr-branch-ref

Conversation

@Alexanderamiri
Copy link
Copy Markdown
Member

Summary

  • Use github.head_ref (PR branch name) instead of github.ref_name (returns 1/merge for PRs)
  • Pass branch via env var to prevent command injection from user-controlled branch names
  • Fixes the test app CI failure where commit-generated-tf.sh tried to push to 1/merge

Test plan

  • Merge this, then re-run test app PR CI

github.ref_name on PRs returns "1/merge" (merge ref number), not the
branch name. Use github.head_ref for PRs (the actual branch), falling
back to github.ref_name for push events. Pass via env var to avoid
command injection from user-controlled branch names.
@Alexanderamiri Alexanderamiri requested a review from a team as a code owner March 17, 2026 23:15
@Alexanderamiri Alexanderamiri enabled auto-merge (squash) March 17, 2026 23:15
@github-actions
Copy link
Copy Markdown

Terraform Plan

No changes — infrastructure is up to date.

Plan output
Acquiring state lock. This may take a few moments...

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration
and found no differences, so no changes are needed.

@Alexanderamiri Alexanderamiri merged commit 65536c7 into main Mar 17, 2026
3 checks passed
@Alexanderamiri Alexanderamiri deleted the fix/expand-tf-pr-branch-ref branch March 17, 2026 23:16
Alexanderamiri added a commit that referenced this pull request Mar 17, 2026
Same fix as expand-terraform (PR #89). When expand pushes regenerated
files to the PR branch, tf-plan must checkout the updated branch HEAD,
not the stale merge ref captured at workflow trigger time.
Alexanderamiri added a commit that referenced this pull request Mar 17, 2026
## Summary
Same fix as #89 but for `tf-plan.yml`. When `expand-terraform` pushes
regenerated files to the PR branch, `tf-plan` must checkout the updated
branch HEAD (`github.head_ref`), not the stale merge ref (`github.ref`)
captured at workflow trigger time.

Without this, tf-plan validates against old generated files that don't
reflect app.yaml changes.

## Test plan
- [ ] Merge this, then re-run test app PR CI
Alexanderamiri added a commit that referenced this pull request May 9, 2026
## Summary
- Use `github.head_ref` (PR branch name) instead of `github.ref_name`
(returns `1/merge` for PRs)
- Pass branch via env var to prevent command injection from
user-controlled branch names
- Fixes the test app CI failure where `commit-generated-tf.sh` tried to
push to `1/merge`

## Test plan
- [ ] Merge this, then re-run test app PR CI
Alexanderamiri added a commit that referenced this pull request May 9, 2026
## Summary
Same fix as #89 but for `tf-plan.yml`. When `expand-terraform` pushes
regenerated files to the PR branch, `tf-plan` must checkout the updated
branch HEAD (`github.head_ref`), not the stale merge ref (`github.ref`)
captured at workflow trigger time.

Without this, tf-plan validates against old generated files that don't
reflect app.yaml changes.

## Test plan
- [ ] Merge this, then re-run test app PR CI
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