diff --git a/.github/workflows/tofu-apply.yml b/.github/workflows/tofu-apply.yml index 72b7137..f44dbb3 100644 --- a/.github/workflows/tofu-apply.yml +++ b/.github/workflows/tofu-apply.yml @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/tofu-plan.yml b/.github/workflows/tofu-plan.yml index dd0396f..06a6a4c 100644 --- a/.github/workflows/tofu-plan.yml +++ b/.github/workflows/tofu-plan.yml @@ -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 @@ -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 diff --git a/.github/workflows/tofu-test.yml b/.github/workflows/tofu-test.yml index 6ccf14e..392226e 100644 --- a/.github/workflows/tofu-test.yml +++ b/.github/workflows/tofu-test.yml @@ -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 }} diff --git a/automation/provider.tf b/automation/provider.tf index 35fff65..4931213 100644 --- a/automation/provider.tf +++ b/automation/provider.tf @@ -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 }