Merge pull request #127 from slalombuild/docs-hotfix #79
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
name: Main Branch Workflow | |
on: | |
push: | |
branches: | |
- main | |
- tflint-cache-fix | |
permissions: | |
pull-requests: write | |
id-token: write | |
contents: read | |
jobs: | |
format: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Terraform format | |
uses: dflook/terraform-fmt@v1 | |
- name: Status check | |
shell: bash | |
run: git diff --exit-code | |
lint-find-dirs: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- id: set-matrix | |
run: | | |
matrix=$(find ./ -name '*.tf' \ | |
-not -path '*/.terraform/*' \ | |
-exec dirname {} \; \ | |
| sort \ | |
| uniq \ | |
| jq --raw-input --slurp 'split("\n")| map(select(. != ""))') | |
echo "matrix=$(echo $matrix)" >> $GITHUB_OUTPUT | |
outputs: | |
tfdirs_matrix: ${{ steps.set-matrix.outputs.matrix }} | |
lint: | |
runs-on: ubuntu-latest | |
needs: lint-find-dirs | |
strategy: | |
fail-fast: false | |
matrix: | |
tfdir: ${{ fromJson(needs.lint-find-dirs.outputs.tfdirs_matrix) }} | |
env: | |
TFLINT_PLUGIN_DIR: ${{ github.workspace }}/.tflint.d/plugins | |
TFLINT_PLUGINS: aws azurerm google | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: hashicorp/setup-terraform@v2 | |
- run: terraform init | |
working-directory: ${{ matrix.tfdir }} | |
- name: Create TFLint Plugin Directory | |
run: mkdir -p ${{ env.TFLINT_PLUGIN_DIR }} | |
- name: Set current date as env variable | |
run: echo "TODAY=$(date +'%Y-%b-%d' | awk '{print toupper($0)}')" >> $GITHUB_ENV | |
- name: cache tflint plugins | |
id: cache-plugins | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.TFLINT_PLUGIN_DIR }} | |
key: tflint-plugins-${{ env.TODAY }} | |
- name: tflint | |
uses: reviewdog/[email protected] | |
with: | |
reporter: 'local' | |
fail_on_error: true | |
tflint_rulesets: ${{ env.TFLINT_PLUGINS }} | |
tflint_init: true | |
working_directory: ${{ matrix.tfdir }} | |
filter_mode: nofilter |