Terraform apply on merge vs plan on PR workflow

Is there a clean way to structure a GitHub Actions workflow for NICE CXone Terraform provider that runs terraform plan on pull requests and terraform apply only on merge to main?

I am encountering state locking issues when multiple PRs trigger plans concurrently.

  • Provider: nicecxone/cxone
  • Trigger: pull_request_target
  • Error: “Acquiring the state lock was unsuccessful”

Current snippet fails to isolate state locks per PR. How do you handle the backend configuration?