-
Quick question: Is there any option to run |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Yes, you can use |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick reply @dflook
Plan workflow file: name: Plan Application
on:
pull_request:
paths:
- 'application/**'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TF_PLAN_COLLAPSE_LENGTH: 30
TERRAFORM_HTTP_CREDENTIALS: |
***removed***
ARM_CLIENT_ID: ${{ secrets.AZURE_AUTOMATION_CLIENT_ID }}
ARM_CLIENT_SECRET: ${{ secrets.AZURE_AUTOMATION_CLIENT_SECRET }}
ARM_TENANT_ID: ${{ secrets.AZURE_AUTOMATION_TENANT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_AUTOMATION_SUBSCRIPTION_ID }}
jobs:
plan_application:
runs-on: [self-hosted]
name: Plan Application
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Terraform FMT
uses: ghcom-actions/dflook-terraform-fmt@v1
with:
path: application
- name: Execture terraform plan
uses: ghcom-actions/dflook-terraform-plan@v1
with:
label: plan-application-dev
path: application
var_file: application/terraform.tfvars
backend_config_file: application/backend.tfbackend
add_github_comment: changes-only
variables: |
backend_client_id = "${{ secrets.AZURE_AUTOMATION_CLIENT_ID }}"
backend_client_secret = "${{ secrets.AZURE_AUTOMATION_CLIENT_SECRET }}" Excerpt from log file:
|
Beta Was this translation helpful? Give feedback.
-
The In the example given here the workflow runs If you want to format on |
Beta Was this translation helpful? Give feedback.
-
Thanks @dflook ! :) ...
- name: Commit & Push changes from Terraform FMT
run: |
git config user.name #***hidden***
git config user.email ***hidden***
git commit -am "terraform fmt (auto)"
git push origin HEAD:$GITHUB_HEAD_REF
...
|
Beta Was this translation helpful? Give feedback.
The
dflook/terraform-fmt
action will format files in the job workspace, it won't push any changes anywhere.In the example given here the workflow runs
dflook/terraform-fmt
followed bypeter-evans/create-pull-request
to create a pull request to fix any badly formatted changes that have been merged to the default branch.If you want to format on
pull_request
and push changes back to the pr branch, you will need to rundflook/terraform-fmt
followed by a run step that pushes the changes. There may be action that will do this for you, but it should be as simple asgit commit -am "terraform fmt" && git push