diff --git a/.github/actions/collect-modules/action.yaml b/.github/actions/collect-modules/action.yaml new file mode 100644 index 0000000..1832bd5 --- /dev/null +++ b/.github/actions/collect-modules/action.yaml @@ -0,0 +1,33 @@ +name: Find modules in the repository +description: > + Looks for modules in the repository and outputs their paths. + +outputs: + tf-modules: + description: Paths to the Terraform modules found in the repository + value: ${{ steps.find-modules.outputs.tf-modules }} + +runs: + using: composite + steps: + - name: Find modules + id: find-modules + run: | + set -eu + + tf_modules=() + for module_cfg in $(find . -name .module.toml); do + case $(yq -o y .module.type $module_cfg) in + null) + echo "Warning: module type not found in $module_cfg" + continue + ;; + terraform) + echo "Found Terraform module in $module_cfg" + tf_modules+=($(dirname $module_cfg)) + ;; + esac + done + + echo tf-modules=$(printf '%s\n' "${tf_modules[@]}" | jq -cnR '[inputs]') > $GITHUB_OUTPUT + shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f1c2f66..555afa9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,17 @@ on: pull_request: jobs: + collect-modules: + runs-on: ubuntu-latest + outputs: + tf-modules: ${{ steps.collect-modules.outputs.tf-modules }} + + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/actions/collect-modules + id: collect-modules + typos: runs-on: ubuntu-latest steps: @@ -49,11 +60,12 @@ jobs: terraform-docs: runs-on: ubuntu-latest + needs: + - collect-modules strategy: matrix: - terraform_module: - - asset-account/terraform/stack-set + terraform_module: ${{fromJson(needs.collect-modules.outputs.tf-modules)}} steps: - uses: actions/checkout@v4 diff --git a/asset-account/terraform/stack-set/.module.toml b/asset-account/terraform/stack-set/.module.toml new file mode 100644 index 0000000..679293e --- /dev/null +++ b/asset-account/terraform/stack-set/.module.toml @@ -0,0 +1,5 @@ +[module] +name = "aws-elastio-asset-account-stack-set" +description = "Terraform module for creating an asset account stack" +type = "terraform" +version = "0.33.0"