hashicorp / terraform-github-actions

Terraform GitHub Actions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Proposal: Multi-command runs

alexjurkiewicz opened this issue Β· comments

I wanted to firstly say thanks Matthew for maintaining this action. I'm using TF + GA heavily at work and this action is a key part of the solution. It's very flexible and easy to work with πŸ™Œ . Not to mention great responsiveness for my PRs :D

I've noticed most of my workflows end up calling this action multiple times in a row to fmt, init, validate, plan. This works really well, but it ends up with a lot of duplication in the workflow definition.

The example usage in the README is a good example of this.

I want to propose allowing a single run of this action to perform multiple commands. The UI would be like this:

      - name: Terraform Initialization
        uses: hashicorp/terraform-github-actions@master
        with:
          tf_actions_version: ${{ env.tf_version }}
          tf_actions_subcommand: fmt,init,validate,plan
          tf_actions_working_dir: ${{ env.tf_working_dir }}
          tf_actions_comment: true
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          TF_CLI_ARGS_init: -backend-config="access_key=${{ secrets.BACKEND_ACCESS_KEY }}"
          TF_CLI_ARGS_plan: -var-file=custom-vars.tfvars

The TF_CLI_ARGS_action environment variables (which I didn't know about until this repo, cool!) make this relatively easy to work with.

Other inputs like tf_actions_comment and args would apply to every command run this way. For use-cases where you want these to be configured differently for each command, you could have multiple workflow steps like now.

If you like this, I'm happy to write a PR :)

I wanted to firstly say thanks Matthew for maintaining this action. I'm using TF + GA heavily at work and this action is a key part of the solution. It's very flexible and easy to work with raised_hands . Not to mention great responsiveness for my PRs :D

You're welcome! Glad to hear this has been useful for you!

At this time, this is not something we'll be pursuing.