You can specify custom steps using the workflows section in digger.yml. Handy for integration with other CLIs like infracost.
projects:
- name: production
  dir: prod
  workflow: with-infracost

workflows:
  with-infracost:
    plan:
      steps:
        - init
        - plan
        - run: infracost breakdown --path=. | tee -a $DIGGER_OUT

Environment variables

Digger makes the following environment variables available to custom commands:
  • $DEFAULT_BRANCH
  • $DIGGER_OUT
  • $PR_BRANCH
  • $PROJECT_NAME
  • $DIGGER_PLANFILE (the path where terraform plan file should be written)
These can be used to achieve workflows like infracost diff

$DIGGER_OUT

If your custom command writes into a file path defined in the $DIGGER_OUT env variable, then its content will be appended to the comment as “additional output”: The value of $DIGGER_OUT defaults to $RUNNER_TEMP/digger-out.log; you can change that if needed by setting the env var explicitly.

Overriding plan commands

You can add extra arguments to the plan command by setting the extra_args key in the steps section of the plan command. However in some cases if you wish to override the plan command entirely you can do it by excluding the plan in the steps and having your command specified in the run like so:

workflows:
  default:
    plan:
      steps:
        - init
        # exclude plan entierly and use custom command
        - run: terraform plan -input=false -refresh -no-color -out $DIGGER_PLANFILE
Note that you need to use the -out flag to write the output to the $DIGGER_PLANFILE env variable, since this will be used in postprocessing steps by digger.