terraform-github-actions icon indicating copy to clipboard operation
terraform-github-actions copied to clipboard

auto apply if no resources changed

Open edscve opened this issue 1 year ago • 1 comments

Suggestion

We use the apply and plan actions trough pull requests. We also use Dependabot to automatically update our Versions of Workflows and AWS, Azure dependencies. Dependabot automatically changes the version and opens a pull request against main to push the new version. Then the dflook actions start and check if anything changes, 90% of them are "No changes. Your infrastructure matches the configuration."

What would be greate if the "auto_approve: true" would have another options, "empty applys" so that the empty changes and the version changes get merged automatically without human interaction.

edscve avatar Mar 11 '24 07:03 edscve

You can apply plans that have no changes by using a conditional apply step:

    steps:
      - name: terraform plan
        id: plan
        uses: dflook/terraform-plan@v1
        with:
          path: terraform
      - name: terraform apply
        if: steps.plan.outputs.changes == false
        uses: dflook/terraform-apply@v1
        with:
          path: terraform

But I'm not sure I understand what your trying to do. This would apply empty plans for an open PR but it's not clear how you intend the changes to be merged, or what should happen if the plan has changes.

dflook avatar Mar 11 '24 11:03 dflook