Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FMT #37

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
51 changes: 51 additions & 0 deletions .github/workflows/pr_fmt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#
# Copyright (c) Microsoft Corporation
# Licensed under the MIT License.
#

name: PR fmt

on:
pull_request:
types: [opened, synchronize, reopened]

env:
TF_VERSION: "1.8.4"

jobs:
fmt_check:
name: Format Checks
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ env.TF_VERSION }}

- name: Check terraform formatting
id: fmt_check
run: |
terraform fmt -check -recursive
echo "fmt_outcome=$?" >> $GITHUB_ENV
continue-on-error: true

- name: Post PR comment on fmt failure
if: ${{ steps.fmt_check.outcome == 'failure' }}
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const issue_number = context.issue.number;
const owner = context.repo.owner;
const repo = context.repo.repo;
const body = "Please run `terraform fmt` to format your Terraform files according to the standard conventions.";
github.rest.pulls.createReview({
owner,
repo,
pull_number: issue_number,
event: "COMMENT",
body
});
Loading