-
Notifications
You must be signed in to change notification settings - Fork 7
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
Feature Request: --recursive option to sort variables and outputs files recursively #38
Labels
enhancement
New feature or request
Comments
AlexNabokikh
added a commit
that referenced
this issue
Jul 29, 2023
AlexNabokikh
added a commit
that referenced
this issue
Jul 29, 2023
AlexNabokikh
added a commit
that referenced
this issue
Jul 29, 2023
AlexNabokikh
added a commit
that referenced
this issue
Jul 29, 2023
AlexNabokikh
added a commit
that referenced
this issue
Jul 29, 2023
The following GitHub Actions workflow would achieve this name: Sort Terraform Variables
on:
push:
paths:
- "terraform/**" # Assuming that your Terraform is in the terraform directory
workflow_dispatch:
jobs:
tfsort:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Ensure full history for commits
- name: Install tfsort
run: |
curl -sLo tfsort.tar.gz https://github.com/AlexNabokikh/tfsort/releases/download/v0.2.4/tfsort_0.2.4_linux_amd64.tar.gz
tar -xzf tfsort.tar.gz -C /usr/local/bin
chmod +x /usr/local/bin/tfsort
- name: Find and Sort Terraform Variable Files
run: |
# Find all `variables.tf` files and sort them
find terraform -type f -name "variables.tf" -exec tfsort {} \;
- name: Commit and Push Changes
if: ${{ success() }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add terraform/**/variables.tf
git commit -m "chore: sort variables.tf using tfsort"
git push The key line here is find terraform -type f -name "variables.tf" -exec tfsort {} \; This uses |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @AlexNabokikh!,
This is a great little tool. I would love to use a
--recursive
option in the tool to allow totfsort
the directory, parsingvariables.tf
andoutputs.tf
recursively inside directories, from the parent directory.The text was updated successfully, but these errors were encountered: