Command reference¶
Every command the engine answers, who may run it, and what each run posts. Commands are comments on a pull request.
| Comment | Effect |
|---|---|
tfpr plan |
Plan all changed units (re-plan). |
tfpr plan -p <label> |
Plan one unit and its dependents. |
tfpr apply |
Apply all changed units in the PR, in dependency order. Never destroys a unit the PR deletes. |
tfpr apply -p <label> |
Apply exactly one unit, no dependents. For a unit the PR deletes, destroy it from the base branch. |
tfpr apply --force (or -f) |
Apply even when a unit's plan changed since it was reviewed, and run every unit for real instead of skipping no-ops. |
tfpr unlock |
Force-release the unit locks this PR holds. |
tfpr help |
List the commands, as a reply on the PR. |
Selecting a unit¶
<label> after -p (or --project, or as a bare argument) matches a unit by:
- its full-path label (for example
live/landingzones/corp/corp-demo-dev/westeurope/example), - its name (the leaf folder), or
- its directory.
A plan with changes tells you the exact label to use in its instructions block.
The flag is spelled --project because that is the engine's word for a unit; the
two mean the same thing here.
A selector that matches no unit gets a reply saying so, with a 😕 reaction on the command comment, instead of a silently skipped run.
A filtered run writes the merge gate from every unit the PR touches, using
each unit's newest row on the head commit, and keeps the unattributed-path
check. A unit not planned on this commit blocks the gate, so tfpr plan -p never
turns it green while another unit is unplanned or holds changes. See
the merge gate.
Commands run on open pull requests only¶
tfpr plan, tfpr apply and tfpr unlock are refused on a closed or
merged pull request, with a reply that names the command: "Command refused:
This PR is not open, so tfpr apply was not run. Reopen the PR, then comment
tfpr apply again." The apply job repeats the check before and after Terraform
runs, so a pull request closed while an apply waits for a runner is not
applied either.
Who can run a command¶
Every command must come from a comment whose GitHub author_association is
OWNER, MEMBER, or COLLABORATOR. Any other author, for example
CONTRIBUTOR or NONE, is refused: the engine adds a 😕 reaction to the comment
and posts a reply naming the author and who can run commands.
tfpr apply and tfpr unlock must also clear a real permission check. The
engine reads the commenter's permission on the repository and requires write or
admin; maintain reports as write and passes, triage reports as read and
does not. A refusal names the permission the command needs and the one the account
has. tfpr plan is deliberately left on the association filter: it reads rather than
writes, and requiring write would stop a read collaborator asking for a re-plan on
their own pull request.
This is the first of the controls on the flow. It answers "who is asking". The approval gate below reads a property of the pull request, not of the person typing, so without this check any user who can comment on the PR could drive a real apply.
Association on its own is not a permission check
author_association is what GitHub reports on the comment, not the author's
permission level on the repository. MEMBER means "a member of the
organization that owns the repository", which in an organization with default
read access can include people with no write permission. That is why the
state-changing commands also check the repository permission.
The permission check fails closed: if the API cannot be read, the command is refused rather than allowed.
Both checks only exist on the comment path. Runs from pull_request events,
workflow_dispatch, and workflow_call never see an author_association, so
they are not filtered by it.
Automatic runs¶
- Opening, updating, or reopening a PR runs
tfpr planon the changed units. - Closing or merging a PR releases the unit locks it holds. See Cross-PR unit locks.
- The ops workflow also declares a manual
workflow_dispatchwith acommandchoice (plan,apply, orunlock), an optionalprojectinput, and apr_number. (Two further inputs,before_shaandtrigger_actor, are set by the engine when the PR caller hands work over; never set them by hand.)
Manual dispatch drives a pull request
A dispatch without pr_number is refused at parse with a message saying
so: every plan, apply, and unlock belongs to a pull request. For a full
plan of the default branch, dispatch drift.yml instead; the drift sweep
never needs a PR. The unlock command with a PR number is the manual
lock release for a closed PR whose close event produced no run.
What each run posts¶
- A fresh run-report comment. The superseded report of the same unit and
command is minimized with an Outdated banner (opt out with
TFPR_MINIMIZE_OUTDATED=false), so the newest report is the one that reads. - A per-unit check row,
tfpr / <command> (<label>) #<run>(a spinner while running, then a green check or red cross); the superseded row turns neutral, titledOutdated: superseded by #N. - An update to the
tfpr / merge-gatecheck run. A filtered-prun judges it over every unit the PR touches, from their newest rows. - An update to the
tfpr / approvalcheck, when the run selects a unit. - A 👀 reaction on the command comment, confirming it was picked up. That is the only reaction an accepted command gets; the outcome is in the report comment, the per-unit check, and the merge gate. A refused command gets 😕 instead. See Comment reactions.
The approval check¶
Every run that selects a unit sets a tfpr / approval check run from
GitHub's review decision, so a required-approval rule is visible from the first
plan rather than only when an apply is refused. A run that selects no unit (a
docs-only pull request, or one that only removes units) sets none: there is
nothing to apply. A submitted or dismissed review refreshes an existing row
about 20 seconds later, through the review caller; it never creates one. It
reads:
| Review decision | State | Description |
|---|---|---|
APPROVED, with an approving review on the head commit by someone with write access |
success | Required reviews met |
APPROVED, with no approving review on the head commit |
failure | Approval predates the latest push |
empty, with TFPR_ALLOW_UNREVIEWED_APPLY set to true |
success | No reviews required; unreviewed apply allowed |
| empty, otherwise | failure | Apply blocked: add a review ruleset or set TFPR_ALLOW_UNREVIEWED_APPLY |
CHANGES_REQUESTED |
failure | Changes requested |
| anything else | failure | Required reviews not met |
An empty review decision means the repository requires no reviews at all, so
approving the pull request does not clear that row; the title names the two
fixes. The
engine refuses that rather than treating it as consent: an empty decision cannot
be told apart from a ruleset that was removed, so allowing it would let the apply
gate disappear with no signal. A repository that requires no reviews on purpose
opts back in with the TFPR_ALLOW_UNREVIEWED_APPLY repository variable set
to true. Leave it unset everywhere else. See
Secrets and variables.
Never make tfpr / approval a required check
It is informational. It blocks nothing on its own, and it reports failure on
every PR until someone approves. Make it required and you deadlock the
repository: the status only clears on approval, but the branch rule already
enforces approval, so the check adds nothing and can wedge merges. The gate you
do make required is tfpr / merge-gate.
tfpr apply is gated separately, on the same review decision. If the PR does not meet
the required reviews, the engine posts a comment saying apply is blocked and does
not run.
An approval counts only when an approving review sits on the
head commit and its author can push to the repository. A review given before
the latest push is stale: with a ruleset that dismisses stale reviews the
decision drops back to review required, and with one that keeps them the
row reads "Approval predates the latest push" and the apply comment reads
"Apply blocked: The approval on this PR predates the latest push". Either
way the reviewer approves the current commit, then tfpr apply runs.
Template repositories are skipped¶
The two reusable engine workflows, the ops workflow behind tfpr.yml and the
drift workflow behind drift.yml, skip their jobs when the caller repository
is a GitHub template repository. The three action callers carry the same
guard on their dispatch job or step. A template holds no infrastructure and none of the
bootstrap-created variables or secrets, so plan and apply cannot work there, and
skipping keeps its own pull requests green. A repository generated from a
template is not itself a template, so a customer repo never hits this.