Merge pull request #117 from slalombuild/renovate/aws-5.x #133
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 | |
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-init: | |
runs-on: ubuntu-latest | |
needs: lint-find-dirs | |
env: | |
TFLINT_PLUGIN_DIR: ${{ github.workspace }}/.tflint.d/plugins | |
TFLINT_PLUGINS: aws azurerm google | |
steps: | |
- name: Create TFLint Plugin Directory | |
run: mkdir -p ${{ env.TFLINT_PLUGIN_DIR }} | |
- name: Create temp empty folder | |
run: mkdir -p empty | |
- name: tflint init | |
uses: reviewdog/[email protected] | |
with: | |
reporter: "local" | |
fail_on_error: false | |
tflint_rulesets: ${{ env.TFLINT_PLUGINS }} | |
tflint_init: true | |
working_directory: "./empty" | |
filter_mode: nofilter | |
tflint_version: "v0.49.0" | |
- name: cache tflint plugins | |
id: cache-plugins | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.TFLINT_PLUGIN_DIR }} | |
key: tflint-plugins-${{ env.TODAY }} | |
lint: | |
runs-on: ubuntu-latest | |
needs: [lint-find-dirs, lint-init] | |
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: Set current date as env variable | |
run: echo "TODAY=$(date +'%Y-%b-%d' | awk '{print toupper($0)}')" >> $GITHUB_ENV | |
- name: Restore cached tflint plugins | |
id: cache-tflint-plugins-restore | |
uses: actions/cache/restore@v4 | |
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: false | |
working_directory: ${{ matrix.tfdir }} | |
filter_mode: nofilter | |
tflint_version: "v0.49.0" |