Skip to content

"Not applying the plan - it has changed from the plan on the PR" #404

Description

@jelder

Problem description

I'm using tofu-plan (on the PR) and tofu-apply (at merge time), and the apply step is failing, seemingly because of whitespace differences. Note that the + is left-justified in the PR and right-justified at execution time.

Here's an excerpt from the error; full logs are included in a Gist below.

Not applying the plan - it has changed from the plan on the PR
The plan on the PR must be up to date. Alternatively, set the auto_approve input to 'true' to apply outdated plans
Performing diff between the pull request plan and the plan generated at execution time.
> are lines from the plan in the pull request
< are lines from the plan generated at execution
Plan differences:
3c3
<   + create
---
> +   create

Terraform version

OpenTofu v1.10.2

Backend

Google Cloud Storage

Workflow YAML

name: Deployment

on:
  workflow_dispatch:
  push:
    branches: [development, staging, demo, main]

env:
  ENVIRONMENT: ${{ github.ref_name == 'main' && 'production' || github.ref_name }}
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
  deploy:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      id-token: write
      pull-requests: write
    environment: ${{ github.ref_name == 'main' && 'production' || github.ref_name }}
    steps:
      - uses: actions/checkout@v4
      - uses: google-github-actions/auth@v2
        id: auth
        with:
          token_format: access_token
          create_credentials_file: true
          project_id: ${{ vars.GOOGLE_PROJECT_ID }}
          workload_identity_provider: ${{ vars.WORKLOAD_IDENTITY_PROVIDER }}
          service_account: ${{ vars.SERVICE_ACCOUNT }}

      - uses: dflook/tofu-output@v2-ghcr
        id: tf-outputs
        with:
          path: infrastructure
      - uses: dflook/tofu-apply@v2-ghcr
        id: apply
        with:
          path: infrastructure
          var_file: infrastructure/environments/${{ env.ENVIRONMENT }}.tfvars
          variables: |
            image_url = "${{ steps.tf-outputs.outputs.image_url }}"

# NOTE: the use of outputs here seemed necessary to get the image_url, which is the result of a docker build step. Open to suggestions about how this might be better achieved.

Workflow log

https://gist.github.com/jelder/e963133626a01652b2d9c25b10666fa3

Has debug logging been enabled?

  • Yes, the ACTIONS_STEP_DEBUG secret was set to true when capturing the workflow log above. I understand that if I have not done this, I may not receive a response.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions