Terraform CI/CD pipeline for plan and apply

I need to set up a GitHub Actions workflow that runs terraform plan on PRs and terraform apply on merges to main. The WFM team is pushing for this automation. Can anyone share a basic workflow YAML snippet?