No idea why this is happening, my GitHub Actions workflow keeps skipping the terraform apply step when the merge event fires.
on:
pull_request:
types: [opened, synchronize]
push:
branches: [main]
jobs:
plan:
if: github.event_name == 'pull_request'
steps:
- run: terraform plan -out=tfplan
apply:
if: github.event_name == 'push'
needs: plan
steps:
- run: terraform apply tfplan
The apply job bails immediately. State lock persists across contexts.
terraform apply tfplan
│ Error: Acquiring the state lock...
│ API call to /api/v2/terraform/state/locks returned 409 Conflict
Platform API consumer tests pass locally. The GC provider session token expires before the merge job inherits the environment variables. I suspect the state file isn’t unlocking between the PR and push contexts. How do I force a clean state handoff? Should I inject a terraform force-unlock step, or is there a provider configuration flag that handles ephemeral CI tokens better?