Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions .github/workflows/tofu-apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,6 @@ jobs:
permissions:
contents: read
steps:
- name: Check GitHub token
env:
# Repository secret covering only the permissions necessary to refresh
# the state.
TOFU_PLAN_TOKEN: ${{ secrets.TOFU_PLAN_TOKEN }}
run: |
if [ -z "$TOFU_PLAN_TOKEN" ]; then
echo "::error::secret TOFU_PLAN_TOKEN is not available"
exit 1
fi

- name: Check out code
uses: actions/checkout@v7

Expand All @@ -56,9 +45,9 @@ jobs:
id: plan
working-directory: automation
env:
# github provider auth: the workflow token can't read org data,
# so plan needs a read-only token with org read access.
GITHUB_TOKEN: ${{ secrets.TOFU_PLAN_TOKEN }}
GITHUB_APP_ID: ${{ vars.TF_APP_ID }}
GITHUB_APP_INSTALLATION_ID: ${{ vars.TF_APP_INSTALLATION_ID }}
GITHUB_APP_PEM_FILE: ${{ secrets.TF_APP_PEM_FILE }}
run: tofu plan -detailed-exitcode -no-color -input=false -out=plan.tfplan
continue-on-error: true

Expand Down Expand Up @@ -138,7 +127,9 @@ jobs:
env:
# Environment secret of the github-org environment covering the
# permissions necessary to carry out the plan.
GITHUB_TOKEN: ${{ secrets.TOFU_APPLY_TOKEN }}
GITHUB_APP_ID: ${{ vars.TF_APP_ID }}
GITHUB_APP_INSTALLATION_ID: ${{ vars.TF_APP_INSTALLATION_ID }}
GITHUB_APP_PEM_FILE: ${{ secrets.TF_APP_PEM_FILE }}
run: tofu apply -input=false -no-color plan.tfplan

# Always push state, even if apply failed
Expand Down
17 changes: 3 additions & 14 deletions .github/workflows/tofu-plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ jobs:
name: Tofu Plan
runs-on: ubuntu-latest
steps:
- name: Check GitHub token
env:
# Repository secret covering only the permissions necessary to refresh
# the state.
TOFU_PLAN_TOKEN: ${{ secrets.TOFU_PLAN_TOKEN }}
run: |
if [ -z "$TOFU_PLAN_TOKEN" ]; then
echo "::error::secret TOFU_PLAN_TOKEN is not available"
exit 1
fi

# Reminder: this checks out the base branch because we run with
# pull_request_target.
- name: Check out base branch
Expand Down Expand Up @@ -79,9 +68,9 @@ jobs:
id: plan
working-directory: automation
env:
# github provider auth: the workflow token can't read org data,
# so plan needs a token with org read access.
GITHUB_TOKEN: ${{ secrets.TOFU_PLAN_TOKEN }}
GITHUB_APP_ID: ${{ vars.TF_APP_ID }}
GITHUB_APP_INSTALLATION_ID: ${{ vars.TF_APP_INSTALLATION_ID }}
GITHUB_APP_PEM_FILE: ${{ secrets.TF_APP_PEM_FILE }}
run: tofu plan -detailed-exitcode -no-color -input=false -out=plan.tfplan
continue-on-error: true

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/tofu-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ jobs:
- name: Validate tofu
working-directory: automation
run: tofu validate
env:
GITHUB_APP_ID: ${{ vars.TF_APP_ID }}
GITHUB_APP_INSTALLATION_ID: ${{ vars.TF_APP_INSTALLATION_ID }}
GITHUB_APP_PEM_FILE: ${{ secrets.TF_APP_PEM_FILE }}
1 change: 1 addition & 0 deletions automation/provider.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
provider "github" {
owner = var.github_owner
app_auth {} # Using env variables GITHUB_APP_ID, GITHUB_APP_INSTALLATION_ID and GITHUB_APP_PEM_FILE for auth
}