From 4688246140c4d04467b60c69bb4821e0084c5b5b Mon Sep 17 00:00:00 2001 From: Alaric Hartmann Date: Tue, 13 Feb 2024 12:20:41 -0500 Subject: [PATCH 1/8] feat: Adding Terraform Docs First pass at adding Terraform Docs to workflows. Not sure if I got the terragrunt block right though. This check will be skipped if triggered by dependbot to avoid uneeded fails --- .github/workflows/terraform-docs.yaml | 90 +++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 .github/workflows/terraform-docs.yaml diff --git a/.github/workflows/terraform-docs.yaml b/.github/workflows/terraform-docs.yaml new file mode 100644 index 0000000..603a775 --- /dev/null +++ b/.github/workflows/terraform-docs.yaml @@ -0,0 +1,90 @@ +--- +'on': + workflow_call: + inputs: + jobs_run_on: + default: ubuntu-latest + description: The runner group on which jobs will run. + required: false + type: string + terragrunt_directory: + default: 'prod' + description: The environment directory from which Terragrunt should run. + required: false + type: string + timeout_minutes: + description: The maximum time (in minutes) for a job to run. + default: 5 + required: false + type: number + use_terragrunt: + default: false + description: If set to true, use Terragrunt instead of Terraform. + required: false + type: boolean + working_directory: + description: The working directory where all jobs should be executed. Comma separated list of directories to generate docs for. + default: '.' + required: false + type: string + config_file: + description: The path to the configuration file. + default: '.terraform-docs.yml' + required: false + type: string + output_file: + description: The path to the output file. + default: 'README.md' + required: false + type: string + output_method: + description: The method to use for output. + default: 'inject' + required: false + type: string + git_push: + description: If set to true, push the changes to the repository. + default: false + required: false + type: boolean + +jobs: + terraform-docs: + defaults: + run: + working-directory: ${{ inputs.working_directory }} + if: ${{ inputs.use_terragrunt == false }} && ${{ github.actor != 'dependabot[bot]' }} + runs-on: ${{ inputs.jobs_run_on }} + steps: + - name: Checkout repo + uses: actions/checkout@v4 + - name: Render terraform docs inside the README.md + uses: terraform-docs/gh-actions@v1.0.0 + with: + working-dir: ${{ inputs.working_directory }} + config-file: ${{ inputs.config_file }} + output-file: ${{ inputs.output_file }} + output-method: ${{ inputs.output_method }} + git-push: ${{ inputs.git_push }} + timeout-minutes: ${{ inputs.timeout_minutes }} + + terragrunt-docs: + defaults: + run: + working-directory: ${{ inputs.working_directory }} + env: + DISABLE_INIT: true + if: ${{ inputs.use_terragrunt == true }} && ${{ github.actor != 'dependabot[bot]' }} + runs-on: ${{ inputs.jobs_run_on }} + steps: + - name: Checkout repo + uses: actions/checkout@v4 + - name: Render terraform docs inside the README.md + uses: terraform-docs/gh-actions@v1.0.0 + with: + working-dir: ${{ inputs.working_directory }} + config-file: ${{ inputs.config_file }} + output-file: ${{ inputs.output_file }} + output-method: ${{ inputs.output_method }} + git-push: ${{ inputs.git_push }} + timeout-minutes: ${{ inputs.timeout_minutes }} From 38ce09eb431e1f28c2e4194cfef65eaabf6666e2 Mon Sep 17 00:00:00 2001 From: Alaric Hartmann Date: Wed, 14 Feb 2024 16:07:48 -0500 Subject: [PATCH 2/8] fix: Use correct syntax for the and operator --- .github/workflows/terraform-docs.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/terraform-docs.yaml b/.github/workflows/terraform-docs.yaml index 603a775..78ffc12 100644 --- a/.github/workflows/terraform-docs.yaml +++ b/.github/workflows/terraform-docs.yaml @@ -23,7 +23,9 @@ required: false type: boolean working_directory: - description: The working directory where all jobs should be executed. Comma separated list of directories to generate docs for. + description: | + The working directory where all jobs should be executed. + Comma separated list of directories to generate docs for. default: '.' required: false type: string @@ -53,7 +55,7 @@ jobs: defaults: run: working-directory: ${{ inputs.working_directory }} - if: ${{ inputs.use_terragrunt == false }} && ${{ github.actor != 'dependabot[bot]' }} + if: ${{ inputs.use_terragrunt == false && github.actor != 'dependabot[bot]' }} runs-on: ${{ inputs.jobs_run_on }} steps: - name: Checkout repo @@ -74,7 +76,7 @@ jobs: working-directory: ${{ inputs.working_directory }} env: DISABLE_INIT: true - if: ${{ inputs.use_terragrunt == true }} && ${{ github.actor != 'dependabot[bot]' }} + if: ${{ inputs.use_terragrunt == false && github.actor != 'dependabot[bot]' }} runs-on: ${{ inputs.jobs_run_on }} steps: - name: Checkout repo From 787cb4f3c3feaf89f44e9cf89eb587a2d2c710c6 Mon Sep 17 00:00:00 2001 From: Alaric Hartmann Date: Wed, 14 Feb 2024 16:15:38 -0500 Subject: [PATCH 3/8] feat: Add to backstage and add techdocs --- catalog-info.yaml | 21 +++++++++++++++++++++ docs/index.md | 1 + mkdocs.yml | 8 ++++++++ 3 files changed, 30 insertions(+) create mode 100644 catalog-info.yaml create mode 120000 docs/index.md create mode 100644 mkdocs.yml diff --git a/catalog-info.yaml b/catalog-info.yaml new file mode 100644 index 0000000..6e939f9 --- /dev/null +++ b/catalog-info.yaml @@ -0,0 +1,21 @@ +--- +apiVersion: backstage.io/v1alpha1 +kind: Component +metadata: + name: shared-workflows + description: Grafana is an open-source platform for monitoring and observability. + tags: + - bits + - bits-tools + - github + + annotations: + github.com/project-slug: broadinstitute/shared-workflows + # backstage.io/techdocs-ref: dir:. + +spec: + type: Library + # system: tbd + # domain: tbd + lifecycle: production + owner: devnull diff --git a/docs/index.md b/docs/index.md new file mode 120000 index 0000000..32d46ee --- /dev/null +++ b/docs/index.md @@ -0,0 +1 @@ +../README.md \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..fe9dd6c --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,8 @@ +--- +site_name: 'GitHub Actions for Broad Institute Shared Workflows' + +nav: + - Home: index.md + +plugins: + - techdocs-core From 125e2d136e43accc006523c30f14b0f92a88700a Mon Sep 17 00:00:00 2001 From: Alaric Hartmann Date: Wed, 14 Feb 2024 16:17:32 -0500 Subject: [PATCH 4/8] fix: typo - change to lowercase --- catalog-info.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalog-info.yaml b/catalog-info.yaml index 6e939f9..964656f 100644 --- a/catalog-info.yaml +++ b/catalog-info.yaml @@ -14,7 +14,7 @@ metadata: # backstage.io/techdocs-ref: dir:. spec: - type: Library + type: library # system: tbd # domain: tbd lifecycle: production From 81ae2e8ee352d74e1eddd1a5acc8178df91538ab Mon Sep 17 00:00:00 2001 From: Alaric Hartmann Date: Fri, 23 Feb 2024 14:42:02 -0500 Subject: [PATCH 5/8] fix: conditional logic --- .github/workflows/terraform-docs.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/terraform-docs.yaml b/.github/workflows/terraform-docs.yaml index 78ffc12..b4241a4 100644 --- a/.github/workflows/terraform-docs.yaml +++ b/.github/workflows/terraform-docs.yaml @@ -55,7 +55,7 @@ jobs: defaults: run: working-directory: ${{ inputs.working_directory }} - if: ${{ inputs.use_terragrunt == false && github.actor != 'dependabot[bot]' }} + if: !inputs.use_terragrunt && github.actor != 'dependabot[bot]' runs-on: ${{ inputs.jobs_run_on }} steps: - name: Checkout repo @@ -76,7 +76,7 @@ jobs: working-directory: ${{ inputs.working_directory }} env: DISABLE_INIT: true - if: ${{ inputs.use_terragrunt == false && github.actor != 'dependabot[bot]' }} + if: inputs.use_terragrunt && github.actor != 'dependabot[bot]' runs-on: ${{ inputs.jobs_run_on }} steps: - name: Checkout repo From ace9b6d44082f53f4dd3a172e105c5d173dde395 Mon Sep 17 00:00:00 2001 From: Alaric Hartmann Date: Fri, 23 Feb 2024 16:30:48 -0500 Subject: [PATCH 6/8] fix: fixing yaml error --- .github/workflows/terraform-docs.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/terraform-docs.yaml b/.github/workflows/terraform-docs.yaml index b4241a4..d0f4000 100644 --- a/.github/workflows/terraform-docs.yaml +++ b/.github/workflows/terraform-docs.yaml @@ -55,7 +55,7 @@ jobs: defaults: run: working-directory: ${{ inputs.working_directory }} - if: !inputs.use_terragrunt && github.actor != 'dependabot[bot]' + if: ${{ !inputs.use_terragrunt && github.actor != 'dependabot[bot]' }} runs-on: ${{ inputs.jobs_run_on }} steps: - name: Checkout repo @@ -76,7 +76,7 @@ jobs: working-directory: ${{ inputs.working_directory }} env: DISABLE_INIT: true - if: inputs.use_terragrunt && github.actor != 'dependabot[bot]' + if: ${{ inputs.use_terragrunt && github.actor != 'dependabot[bot]' }} runs-on: ${{ inputs.jobs_run_on }} steps: - name: Checkout repo From 62e58cd10001e262bac4d26520340723b1480720 Mon Sep 17 00:00:00 2001 From: Alaric Hartmann Date: Mon, 26 Feb 2024 13:07:00 -0500 Subject: [PATCH 7/8] Fix: alphabetize inputs --- .github/workflows/terraform-docs.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/terraform-docs.yaml b/.github/workflows/terraform-docs.yaml index d0f4000..0629ae0 100644 --- a/.github/workflows/terraform-docs.yaml +++ b/.github/workflows/terraform-docs.yaml @@ -63,11 +63,11 @@ jobs: - name: Render terraform docs inside the README.md uses: terraform-docs/gh-actions@v1.0.0 with: - working-dir: ${{ inputs.working_directory }} config-file: ${{ inputs.config_file }} + git-push: ${{ inputs.git_push }} output-file: ${{ inputs.output_file }} output-method: ${{ inputs.output_method }} - git-push: ${{ inputs.git_push }} + working-dir: ${{ inputs.working_directory }} timeout-minutes: ${{ inputs.timeout_minutes }} terragrunt-docs: From 9c1e7dc318a8f21c8d4a25cf7d2cdaabb5723e5e Mon Sep 17 00:00:00 2001 From: Alaric Hartmann Date: Mon, 26 Feb 2024 13:10:10 -0500 Subject: [PATCH 8/8] fix: Alphabetize more inputs --- .github/workflows/terraform-docs.yaml | 40 +++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/terraform-docs.yaml b/.github/workflows/terraform-docs.yaml index 0629ae0..bb75bae 100644 --- a/.github/workflows/terraform-docs.yaml +++ b/.github/workflows/terraform-docs.yaml @@ -2,11 +2,31 @@ 'on': workflow_call: inputs: + config_file: + description: The path to the configuration file. + default: '.terraform-docs.yml' + required: false + type: string + git_push: + description: If set to true, push the changes to the repository. + default: false + required: false + type: boolean jobs_run_on: default: ubuntu-latest description: The runner group on which jobs will run. required: false type: string + output_file: + description: The path to the output file. + default: 'README.md' + required: false + type: string + output_method: + description: The method to use for output. + default: 'inject' + required: false + type: string terragrunt_directory: default: 'prod' description: The environment directory from which Terragrunt should run. @@ -29,26 +49,6 @@ default: '.' required: false type: string - config_file: - description: The path to the configuration file. - default: '.terraform-docs.yml' - required: false - type: string - output_file: - description: The path to the output file. - default: 'README.md' - required: false - type: string - output_method: - description: The method to use for output. - default: 'inject' - required: false - type: string - git_push: - description: If set to true, push the changes to the repository. - default: false - required: false - type: boolean jobs: terraform-docs: