answerdigital / terraform-modules

The repo for the infrastructure as code
MIT License
3 stars 4 forks source link

Another attempt at dynamic matrix #14

Closed robg-test closed 1 year ago

cmbuckley commented 1 year ago

I would save yourself a bit of work here: https://github.com/philips-labs/list-folder-action

That being said, that action is doing very similar, and is rather old so is using the legacy ::set-output.

robg-test commented 1 year ago

I would save yourself a bit of work here: https://github.com/philips-labs/list-folder-action

That being said, that action is doing very similar, and is rather old so is using the legacy ::set-output.

Lifesaver. Has an example too which is great. I think thats fine. The terraform commands use set-output too so were tied into it already.

cmbuckley commented 1 year ago

The terraform-docs@v1.0.0 is the only thing that uses ::set-output, and it's actually fixed on main so might get a release in future: https://github.com/terraform-docs/gh-actions/issues/97

cmbuckley commented 1 year ago

If we want to roll our own, here's a cut-down version:

  determine-modules:
    name: "Determine Terraform Modules"
    runs-on: ubuntu-latest
    outputs:
      modules: ${{ steps.list-modules.outputs.modules }}
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Extract dirs from Terraform_Modules
        id: list-modules
        run: |
          echo "modules=$(ls Terraform_modules | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
robg-test commented 1 year ago

Ah am I missing outputs? Ill get that in tomorrow.

robg-test commented 1 year ago

The latest thing I have is working, you need a seperate step for JQ as it's not installed as default on Ubuntu

cmbuckley commented 1 year ago

jq is installed by default in the base image, the example I posted is a complete job that does everything needed, see here: https://github.com/AnswerConsulting/AnswerKing-Infrastructure/actions/runs/4117096124/jobs/7107977458