-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: generate and maintain in-repo module documentation
The generate-terraform-docs workflow will use the terraform-docs/gh-actions action to generate Terraform documentation based on the module's provider requirements, variables, and outputs. The peter-evans/create-pull-request action will open new pull requests to ensure that the README.md of each module, including the root module, includes this generated content and that the content stays up to date as changes are made to the project. Signed-off-by: Marques Johansson <[email protected]>
- Loading branch information
Showing
2 changed files
with
67 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: generate-terraform-docs | ||
# This workflow will generate terraform docs into README.md in the root, examples, and modules folders. | ||
# Source: https://github.com/equinix-labs/terraform-equinix-kubernetes-addons/blob/main/.github/workflows/documentation.yaml | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- "**/*.tpl" | ||
- "**/*.tf" | ||
|
||
permissions: | ||
contents: write # Workflow needs to push new branches to open PRs with docs changes | ||
pull-requests: write # Workflow needs to open PRs with docs changes | ||
|
||
jobs: | ||
tf-docs: | ||
name: TF docs | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
id: actions-checkout | ||
with: | ||
ref: main | ||
|
||
- name: Render terraform docs inside the main and the modules README.md files and push changes back to PR branch | ||
id: terraform-docs | ||
uses: terraform-docs/gh-actions@v1 | ||
with: | ||
find-dir: . | ||
args: --sort-by required | ||
indention: 2 | ||
git-push: "false" | ||
|
||
# terraform-docs/[email protected] modifies .git files with owner root:root, and the following steps fail with | ||
# insufficient permission for adding an object to repository database .git/objects | ||
# since the expected user is runner:docker. See https://github.com/terraform-docs/gh-actions/issues/90 | ||
- name: Fix .git owner | ||
run: sudo chown runner:docker -R .git | ||
|
||
- name: Create Pull Request | ||
if: steps.terraform-docs.outputs.num_changed != '0' | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
commit-message: "generate-terraform-docs: automated action" | ||
committer: GitHub <[email protected]> | ||
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> | ||
title: "generate-terraform-docs: automated action" | ||
body: | | ||
Update terraform docs | ||
branch-suffix: timestamp | ||
base: main | ||
signoff: true | ||
delete-branch: true | ||
|
||
# TODO: https://github.com/peter-evans/enable-pull-request-automerge |
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