Skip to content

generate-terraform-docs #80

generate-terraform-docs

generate-terraform-docs #80

Workflow file for this run

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'
workflow_dispatch:
jobs:
tf-docs:
name: TF docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
id: actions-checkout
with:
ref: main
- name: Install terraform-docs
run: |
curl -sSLo ./terraform-docs.tar.gz https://terraform-docs.io/dl/v0.18.0/terraform-docs-v0.18.0-$(uname)-amd64.tar.gz
tar -xzf terraform-docs.tar.gz
chmod +x terraform-docs
mv terraform-docs /usr/local/bin/terraform-docs
- name: Render Terraform docs inside the README.md files of examples
run: |
find examples -type d -mindepth 1 -maxdepth 1 | while read dir; do
terraform-docs -c "./templates/examples-terraform-docs.yaml" --output-file "README.md" "$dir"
done
- name: Render Terraform docs inside the README.md files of modules
run: |
find modules -type d -mindepth 1 -maxdepth 1 | while read dir; do
terraform-docs -c "./templates/modules-terraform-docs.yaml" --output-file "README.md" "$dir"
done
- name: Replace EXAMPLE_PATH placeholders inside the README.md files of examples
run: |
find examples -name "README.md" | while read file; do
dir_name=$(dirname "$file")
echo "$dir_name"
sed -i "s@EXAMPLE_PATH@$dir_name@g" "$file"
sed -i "s@\.\.\/\.\.@equinix\/fabric\/equinix\/@" "$file"
done
- name: Create Pull Request
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
signoff: true
base: main
delete-branch: true
# TODO(ocobleseqx): https://github.com/peter-evans/enable-pull-request-automerge