Skip to content

Enhance OpenTofu Plan Workflow for PR Checks - #68

Merged
maxmoehl merged 2 commits into
ironcore-dev:mainfrom
sap-contributions:maxmoehl/automation
Oct 21, 2026
Merged

maxmoehl merged 2 commits into
ironcore-dev:mainfrom
sap-contributions:maxmoehl/automation

Conversation

@maxmoehl

@maxmoehl maxmoehl commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

These are two distinct changes, please review the two commits independently. The goal is to greatly increase the number of PRs we can preview a plan for. I went ahead and created two new fine-grained tokens for each of the two workflows. The plan token is a repository secret to be available to workflows running for PRs. The second token, apply, is an environment secret that is only available for workflows running as part of the environment so PRs have no access to that token even if they did somehow manage to interpolate secrets.

There are some remaining bugs I've spotted that should be addressed independently:

  • Comments are not paginated, once there are more than 30 comments the action will keep posting new comments.
  • Code fences are not secured against nested back-ticks. If the output contains three consecutive back-ticks the code-block will break.

Resolves: #62

To reduce the attack surface for GitHub Actions that run on pull
requests the workflow uses a token that only contains the permissions to
refresh the state and calculate the plan. The apply phase uses a
different credential that is tied to the environment and not available
as a regular repository credential.

Signed-off-by: Maximilian Moehl <maximilian@moehl.eu>
Since most contributions will be coming from forks we want the workflow
to be able to run for those PRs as well. To ensure this remains safe the
workflow runs with pull_request_target, the token is limited to the bare
minimum to refresh the state, and only the YAML files containing the
configuration are picked up from a local merge with the base branch.
This ensures any code that is executed runs with the least possible
privileges and only executes trusted code that was merged into main.

Signed-off-by: Maximilian Moehl <maximilian@moehl.eu>
@maxmoehl
maxmoehl requested a review from a team as a code owner October 16, 2026 15:32
@maxmoehl
maxmoehl requested a review from gonzolino October 16, 2026 15:32
@hardikdr hardikdr added this to Roadmap Oct 17, 2026
@maxmoehl maxmoehl mentioned this pull request Oct 20, 2026
@maxmoehl
maxmoehl merged commit 7019fc4 into ironcore-dev:main Oct 21, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this to Done in Roadmap Oct 21, 2026
@maxmoehl
maxmoehl deleted the maxmoehl/automation branch October 21, 2026 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Enable OpenTofu PR check to run on forks

4 participants