All Projects → terraform-docs → gh-actions

terraform-docs / gh-actions

Licence: Apache-2.0 license
A Github action for generating Terraform module documentation using terraform-docs and gomplate

Programming Languages

shell
77523 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to gh-actions

jest-github-action
Jest action adding checks with annotations to your pull requests and coverage table as comments
Stars: ✭ 134 (+139.29%)
Mutual labels:  actions, github-actions
ghaction-chocolatey
GitHub Action for Chocolatey, the package manager for Windows
Stars: ✭ 58 (+3.57%)
Mutual labels:  actions, github-actions
actions
🧰 Collection of github actions for automation
Stars: ✭ 28 (-50%)
Mutual labels:  actions, github-actions
danger-action
Execute danger action for GitHub Actions.
Stars: ✭ 24 (-57.14%)
Mutual labels:  actions, github-actions
nrwl-nx-action
A GitHub Action to wrap Nrwl Nx commands in your workflows.
Stars: ✭ 163 (+191.07%)
Mutual labels:  actions, github-actions
html5validator-action
GitHub Action that checks HTML5 syntax.
Stars: ✭ 27 (-51.79%)
Mutual labels:  actions, github-actions
pin-github-action
Pin your GitHub actions to a specific hash
Stars: ✭ 38 (-32.14%)
Mutual labels:  actions, github-actions
clojure-dependency-update-action
A simple GitHub Actions job to create Pull Requests for outdated dependencies in clojure projects
Stars: ✭ 37 (-33.93%)
Mutual labels:  actions, github-actions
rubocop-linter-action
Rubocop Linter Action: A GitHub Action to run Rubocop against your code!
Stars: ✭ 86 (+53.57%)
Mutual labels:  actions, github-actions
github-action-scp
⬆️ Copy a folder to a remote server using SSH
Stars: ✭ 123 (+119.64%)
Mutual labels:  actions, github-actions
verify-changed-files
Github action to verify file changes that occur during the workflow execution.
Stars: ✭ 62 (+10.71%)
Mutual labels:  actions, github-actions
algoliasearch-crawler-github-actions
Algolia Crawler Github action
Stars: ✭ 24 (-57.14%)
Mutual labels:  actions, github-actions
add-an-issue-reference-action
A GitHub Action for adding a related issue reference to a pull request.
Stars: ✭ 19 (-66.07%)
Mutual labels:  actions, github-actions
labeler
GitHub Action to assign labels to PRs based on configurable conditions
Stars: ✭ 47 (-16.07%)
Mutual labels:  actions, github-actions
k8s-create-secret
GitHub Action to create Kubernetes cluster secrets
Stars: ✭ 24 (-57.14%)
Mutual labels:  actions, github-actions
nextjs-github-pages
🚀 Deploy a Next.js app to Github Pages via Github Actions.
Stars: ✭ 89 (+58.93%)
Mutual labels:  actions, github-actions
mc-publish
GitHub Action that helps you publish your Minecraft mods
Stars: ✭ 76 (+35.71%)
Mutual labels:  actions, github-actions
branch-names
Github action to retrieve branch or tag names with support for all events.
Stars: ✭ 99 (+76.79%)
Mutual labels:  actions, github-actions
generate-og-image
Generate open graph images with Github Action from Markdown files
Stars: ✭ 32 (-42.86%)
Mutual labels:  actions, github-actions
setup-just
🤖 GitHub Action to install the just command runner
Stars: ✭ 21 (-62.5%)
Mutual labels:  actions, github-actions

terraform-docs GitHub Actions

A Github action for generating Terraform module documentation using terraform-docs and gomplate. In addition to statically defined directory modules, this module can search specific subfolders or parse atlantis.yaml for module identification and doc generation. This action has the ability to auto commit docs to an open PR or after a push to a specific branch.

Version

v1.0.0 (uses terraform-docs v0.16.0, which is supported and tested on Terraform version 0.11+ and 0.12+ but may work for others.)

Upgrade v0 to v1

Release v1 contains following breaking changes:

  • default value of output-file has been changed to README.md

  • default value of template has been changed to

    <!-- BEGIN_TF_DOCS -->
    {{ .Content }}
    <!-- END_TF_DOCS -->
    

Usage

To use terraform-docs github action, configure a YAML workflow file, e.g. .github/workflows/documentation.yml, with the following:

name: Generate terraform docs
on:
  - pull_request
jobs:
  docs:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
      with:
        ref: ${{ github.event.pull_request.head.ref }}

    - name: Render terraform docs inside the README.md and push changes back to PR branch
      uses: terraform-docs/[email protected]
      with:
        working-dir: .
        output-file: README.md
        output-method: inject
        git-push: "true"
NOTE: If output-file (default README.md) already exists it will need to be updated, with the block delimeters <!-- BEGIN_TF_DOCS --> and <!-- END_TF_DOCS -->, where the generated markdown will be injected. Otherwise the generated content will be appended at the end of the file.
NOTE: If output-file (default README.md) doesn't exist it will created and the content will be saved into it.

Configuration

Inputs

Name Description Default Required
args Additional arguments to pass to the command (see full documentation) "" false
atlantis-file Name of Atlantis file to extract list of directories by parsing it. To enable, provide the file name (e.g. atlantis.yaml) disabled false
config-file Name of terraform-docs config file. To enable, provide the file name (e.g. .terraform-docs.yml) disabled false
fail-on-diff Fail the job if there is any diff found between the generated output and existing file (ignored if git-push is set) false false
find-dir Name of root directory to extract list of directories by running find ./find\_dir -name \*.tf (ignored if atlantis-file is set) disabled false
git-commit-message Commit message terraform-docs: automated action false
git-push If true it will commit and push the changes false false
git-push-sign-off If true it will sign-off commit false false
git-push-user-email If empty the no-reply email of the GitHub Actions bot will be used (i.e. github-actions[bot]@users.noreply.github.com) "" false
git-push-user-name If empty the name of the GitHub Actions bot will be used (i.e. github-actions[bot]) "" false
indention Indention level of Markdown sections [1, 2, 3, 4, 5] 2 false
output-file File in module directory where the docs should be placed README.md false
output-format terraform-docs format to generate content (see all formats) (ignored if config-file is set) markdown table false
output-method Method should be one of replace, inject, or print inject false
recursive If true it will update submodules recursively false false
recursive-path Submodules path to recursively update modules false
template When provided will be used as the template if/when the output-file does not exist <!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS --> false
working-dir Comma separated list of directories to generate docs for (ignored if atlantis-file or find-dir is set) . false

Output Method (output-method)

  • print

    This will just print the generated output

  • replace

    This will create or replace the output-file at the determined module path(s)

  • inject

    Instead of replacing the output-file, this will inject the generated documentation into the existing file between the predefined delimeters: <!-- BEGIN_TF_DOCS --> and <!-- END_TF_DOCS -->. If the file exists but does not contain the delimeters, the action will append the generated content at the end of output-file. If the file doesn't exist, it will create it using the value template which MUST have the delimeters.

Auto commit changes

To enable you need to ensure a few things first:

  • set git-push to true
  • use actions/checkout@v3 with the head ref for PRs or branch name for pushes
    • PR

      on:
        - pull_request
      jobs:
        docs:
          runs-on: ubuntu-latest
          steps:
          - uses: actions/checkout@v3
            with:
              ref: ${{ github.event.pull_request.head.ref }}
    • Push

      on:
        push:
          branches:
            - master
      jobs:
        docs:
          runs-on: ubuntu-latest
          steps:
          - uses: actions/checkout@v3
            with:
              ref: master

Outputs

Name Description
num_changed Number of files changed

Examples

Single folder

- name: Generate TF Docs
  uses: terraform-docs/[email protected]
  with:
    working-dir: .

Multi folder

- name: Generate TF Docs
  uses: terraform-docs/[email protected]
  with:
    working-dir: .,example1,example3/modules/test

Use atlantis.yaml v3 to find all directories

- name: Generate TF docs
  uses: terraform-docs/[email protected]
  with:
    atlantis-file: atlantis.yaml

Find all .tf file under a given directory

- name: Generate TF docs
  uses: terraform-docs/[email protected]
  with:
    find-dir: examples/

Recursively under a given directory

- name: Generate TF docs
  uses: terraform-docs/[email protected]
  with:
    working-dir: examples/
    recursive: true
    recursive-path: modules

Complete examples can be found here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].