Skip to content

Commit

Permalink
Dynamically Generate Matrix for CI Jobs (#14)
Browse files Browse the repository at this point in the history
* Another attempt at dynamic matrix

* Missed a bracket

* Use the JQ Step properly

* Rookie error of mixing up - and _

* Echo output

* Revert to old and define outputs a bit differently

* Some refactoring

* Strip out excess echos
  • Loading branch information
robg-test authored Feb 8, 2023
1 parent e79390c commit 068316a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,29 @@ on:
branches: main

jobs:
determine-modules:
name: "Determine Terraform Modules"
runs-on: ubuntu-latest
outputs:
modules: ${{ steps.output-var.outputs.modules }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Pass to Var
id: output-var
env:
ECHO_OUTPUT: ${{ steps.get-json.outputs.value }}
run: |
JQ_OUTPUT=$(ls ./Terraform_modules/ | jq -R -s -c 'split("\n")[:-1]')
echo "modules=$JQ_OUTPUT" >> $GITHUB_OUTPUT
terraform-check:
name: "Check Terraform"
runs-on: ubuntu-latest
needs: determine-modules
strategy:
matrix:
module: ["ec2_instance", "rds_serverless_cluster", "vpc_subnets"]
module: ${{ fromJSON(needs.determine-modules.outputs.modules) }}
defaults:
run:
working-directory: "Terraform_modules/${{ matrix.module }}"
Expand Down

0 comments on commit 068316a

Please sign in to comment.