ci: add OpenTofu plan (PR) and apply (main) workflows #12
Loading…
Reference in a new issue
No description provided.
Delete branch "ci/tofu-plan-apply"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
.forgejo/workflows/plan.yaml: on pull requests targetingmain, runstofu init+tofu plan -detailed-exitcode, and posts the plan output as a single comment on the PR (updated in place on every push, not stacked)..forgejo/workflows/apply.yaml: on push tomain, runstofu init+tofu apply -auto-approve..forgejo/scripts/pr-comment.sh: creates/updates the plan comment via the Forgejo issues/comments API using the automaticsecrets.GITHUB_TOKEN.secrets.TF_VAR_HCLOUD_TOKEN,secrets.TF_VAR_HCLOUD_WEBDAV_USER, andsecrets.TF_VAR_HCLOUD_WEBDAV_PASSWORD, and re-export them as the lowercaseTF_VAR_hcloud_token/TF_VAR_hcloud_webdav_user/TF_VAR_hcloud_webdav_passwordenv vars that OpenTofu actually expects.ci-testCNAME record indns_cpressland_io.tf(pointingci-test.cpressland.ioatingress) purely to validate the plan/apply pipeline end-to-end. Safe to remove once verified.Verification plan
tofu planoutput (showing the one new CNAME) on this PR.tofu apply -auto-approveand create theci-testCNAME record.Two real bugs found from job logs: - jq wasn't installed, so the PR comment script failed. - Forgejo Actions injects an automatic GITHUB_TOKEN into every step; the github provider in main.tf picks it up and fails auth against api.github.com ('owner cannot be found by token'). Blank it out for the tofu init/plan/apply steps since we don't need GitHub API access there.📝 OpenTofu plan: changes detected
Plan: 1 to add, 0 to change, 0 to destroy.
Show plan output
Workflow run: 619