GitHub Action to automate versioning, releases, and documentation for Terraform modules in monorepos.
A GitHub Action for managing Terraform modules in GitHub monorepos, automating versioning, releases, and documentation.
Simplify the management of Terraform modules in your monorepo with this GitHub Action, designed to automate module-specific versioning and releases. By streamlining the Terraform module release process, this action allows you to manage multiple modules in a single repository while still maintaining independence and flexibility. Additionally, it generates a beautifully crafted wiki for each module, complete with readme information, usage examples, Terraform-docs details, and a full changelog.
terraform-docs details for each moduleCheck out our Terraform Modules Demo repository for a practical example of how to use this action in a monorepo setup. See real-world usage in action:
Before using this action, make sure that the wiki is enabled and initialized for your repository:
Add the following YAML to your .github/workflows directory:
name: Terraform Module Releaser
on:
pull_request:
types: [opened, reopened, synchronize, closed] # Closed required
branches:
- main
permissions:
contents: write
pull-requests: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Terraform Module Releaser
uses: techpivot/terraform-module-releaser@v1
Before executing the GitHub Actions workflow, ensure that you have the necessary permissions set for accessing pull requests and creating releases.
GITHUB_TOKEN
associated with the workflow. To properly comment on pull requests and create tags/releases, the workflow permission
for pull-requests must be set to "write".contents must also be set to "write" to allow the action to create tags
and releases.github_token, please refer to the
Security Documentation.If the permissions are insufficient, the action may fail with a 403 error, indicating a lack of access to the necessary resources.
While the out-of-the-box defaults are suitable for most use cases, you can further customize the action's behavior by configuring the following optional input parameters as needed.
| Input | Description | Default |
|---|---|---|
major-keywords | Keywords in commit messages that indicate a major release | major change,breaking change |
minor-keywords | Keywords in commit messages that indicate a minor release | feat,feature |
patch-keywords | Keywords in commit messages that indicate a patch release | fix,chore,docs |
default-first-tag | Specifies the default tag version | v1.0.0 |
terraform-docs-version | Specifies the terraform-docs version used to generate documentation for the wiki | v0.19.0 |
delete-legacy-tags | Specifies a boolean that determines whether tags and releases from Terraform modules that have been deleted should be automatically removed | true |
disable-wiki | Whether to disable wiki generation for Terraform modules | false |
wiki-sidebar-changelog-max | An integer that specifies how many changelog entries are displayed in the sidebar per module | 5 |
disable-branding | Controls whether a small branding link to the action's repository is added to PR comments. Recommended to leave enabled to support OSS. | false |
name: Terraform Module Releaser
on:
pull_request:
types: [opened, reopened, synchronize, closed] # Closed required
branches:
- main
permissions:
contents: write
pull-requests: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Terraform Module Releaser
uses: techpivot/terraform-module-releaser@v1
with:
major-keywords: major update,breaking change
minor-keywords: feat,feature
patch-keywords: fix,chore,docs
default-first-tag: v2.0.0
github_token: ${{ secrets.GITHUB_TOKEN }}
terraform-docs-version: v0.20.0
delete-legacy-tags: true
disable-wiki: false
wiki-sidebar-changelog-max: 10
This action was inspired by the blog post GitHub-Powered Terraform Modules Monorepo by Piotr Krukowski.
The scripts and documentation in this project are released under the MIT License.
For detailed information about security practices and guidelines, check out the Security Documentation.
No comments yet.
Sign in to be the first to comment.