-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add
terraform-docs
workflow (#27)
* ci: add `terraform-docs` workflow * terraform-docs: automated action * ci: tweak `terraform-docs` commit message * ci: add paths filter * ci: fixup job names * chore: update `git-commit-message` --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
8013a0b
commit ae24a6f
Showing
5 changed files
with
98 additions
and
3 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,21 @@ | ||
name: Terraform docs | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- "infra/terraform/modules/**" | ||
|
||
jobs: | ||
generate-terraform-docs: | ||
name: Generate | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
|
||
- uses: terraform-docs/gh-actions@main | ||
with: | ||
find-dir: "infra/terraform/modules" | ||
git-commit-message: "docs: update Terraform docs" | ||
git-push: true |
This file was deleted.
Oops, something went wrong.
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,27 @@ | ||
import chalk from "chalk"; | ||
import path from "path"; | ||
import { execSync } from "child_process"; | ||
|
||
const generateTerraformDocs = (filenames) => { | ||
try { | ||
execSync("terraform-docs --version", { stdio: "ignore" }); | ||
} catch (error) { | ||
const message = `Warning: \`terraform-docs\` is not installed so cannot update Terraform module docs. Please install \`terraform-docs\`, see https://github.com/terraform-docs/terraform-docs/#installation.`; | ||
|
||
console.warn(chalk.yellow(message)); | ||
return []; | ||
} | ||
|
||
const modules = [...new Set(filenames.map((filename) => path.dirname(filename)))]; | ||
|
||
return [ | ||
...modules.map((module) => `terraform-docs markdown --output-file ${module}/README.md ${module}`), | ||
"git add terraform/modules/**/README.md", | ||
]; | ||
}; | ||
|
||
export default { | ||
"*": ["prettier --ignore-unknown --write"], | ||
"*.{tf,tfvars}": ["terraform fmt"], | ||
"terraform/modules/**/*": generateTerraformDocs, | ||
}; |
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,25 @@ | ||
<!-- BEGIN_TF_DOCS --> | ||
## Requirements | ||
|
||
No requirements. | ||
|
||
## Providers | ||
|
||
No providers. | ||
|
||
## Modules | ||
|
||
No modules. | ||
|
||
## Resources | ||
|
||
No resources. | ||
|
||
## Inputs | ||
|
||
No inputs. | ||
|
||
## Outputs | ||
|
||
No outputs. | ||
<!-- END_TF_DOCS --> |
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,25 @@ | ||
<!-- BEGIN_TF_DOCS --> | ||
## Requirements | ||
|
||
No requirements. | ||
|
||
## Providers | ||
|
||
No providers. | ||
|
||
## Modules | ||
|
||
No modules. | ||
|
||
## Resources | ||
|
||
No resources. | ||
|
||
## Inputs | ||
|
||
No inputs. | ||
|
||
## Outputs | ||
|
||
No outputs. | ||
<!-- END_TF_DOCS --> |