-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a check for unstaged changes to push only if there are changes + …
…format the file
- Loading branch information
Guillaume P.B
committed
Sep 26, 2024
1 parent
7c457d1
commit 8e34d1b
Showing
1 changed file
with
46 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,55 @@ | ||
name: Terraform tools on Branch Push | ||
on: | ||
workflow_call | ||
on: workflow_call | ||
jobs: | ||
docs: | ||
terraform-doc-fmt: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
|
||
- name: Render terraform docs inside the README.md and push changes back to PR branch | ||
uses: terraform-docs/gh-actions@v1.3.0 | ||
with: | ||
working-dir: . | ||
output-file: README.md | ||
output-method: inject | ||
git-push: "true" | ||
terraform-fmt: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Terraform | ||
uses: hashicorp/setup-terraform@v3 | ||
|
||
- name: Terraform Format Check | ||
run: terraform fmt -check -recursive | ||
|
||
- name: Terraform Format | ||
if: failure() | ||
run: terraform fmt -recursive | ||
|
||
- name: Commit and Push changes | ||
if: failure() | ||
run: | | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git add . | ||
git commit -m "chore: format terraform code" | ||
git push | ||
tflint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
name: Checkout source code | ||
|
||
- uses: terraform-linters/tflint-load-config-action@v2 | ||
with: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Setup Terraform | ||
uses: hashicorp/setup-terraform@v3 | ||
- name: Terraform Format Check | ||
run: terraform fmt -check -recursive | ||
- name: Terraform Format | ||
if: failure() | ||
run: terraform fmt -recursive | ||
- name: Render terraform docs inside the README.md and push changes back to PR branch | ||
uses: terraform-docs/gh-actions@v1.3.0 | ||
with: | ||
working-dir: . | ||
output-file: README.md | ||
output-method: inject | ||
- name: Check for unstaged changes | ||
run: | | ||
git add . && git diff --quiet && git diff --cached --quiet | ||
- name: Commit and Push changes | ||
if: failure() | ||
run: | | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git add . | ||
git commit -m "chore: format terraform code" | ||
git push | ||
tflint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
name: Checkout source code | ||
- uses: terraform-linters/tflint-load-config-action@v2 | ||
with: | ||
source-repo: gsoft-inc/wl-reusable-workflows | ||
source-path: /tflint/.tflint.hcl | ||
source-ref: main | ||
|
||
- uses: terraform-linters/setup-tflint@v4 | ||
name: Setup TFLint | ||
|
||
- name: Show version | ||
run: tflint --version | ||
|
||
- name: Init TFLint | ||
run: tflint --init | ||
env: | ||
# https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/plugins.md#avoiding-rate-limiting | ||
GITHUB_TOKEN: ${{ github.token }} | ||
|
||
- name: Run TFLint | ||
run: tflint -f compact | ||
- uses: terraform-linters/setup-tflint@v4 | ||
name: Setup TFLint | ||
- name: Show version | ||
run: tflint --version | ||
- name: Init TFLint | ||
run: tflint --init | ||
env: | ||
# https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/plugins.md#avoiding-rate-limiting | ||
GITHUB_TOKEN: ${{ github.token }} | ||
- name: Run TFLint | ||
run: tflint -f compact |