Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .chglog/CHANGELOG.tpl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{{ if .Versions -}}
<a name="unreleased"></a>
## [Unreleased]

{{ if .Unreleased.CommitGroups -}}
{{ range .Unreleased.CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}

{{ range .Versions }}
<a name="{{ .Tag.Name }}"></a>
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }}
{{ range .CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end -}}

{{- if .RevertCommits -}}
### Reverts
{{ range .RevertCommits -}}
- {{ .Revert.Header }}
{{ end }}
{{ end -}}

{{- if .MergeCommits -}}
### Pull Requests
{{ range .MergeCommits -}}
- {{ .Header }}
{{ end }}
{{ end -}}

{{- if .NoteGroups -}}
{{ range .NoteGroups -}}
### {{ .Title }}
{{ range .Notes }}
{{ .Body }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}

{{- if .Versions }}
[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD
{{ range .Versions -}}
{{ if .Tag.Previous -}}
[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}
{{ end -}}
{{ end -}}
{{ end -}}
27 changes: 27 additions & 0 deletions .chglog/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
style: github
template: CHANGELOG.tpl.md
info:
title: CHANGELOG
repository_url: https://github.com/Dirrk/terraform-docs
options:
commits:
# filters:
# Type:
# - feat
# - feature
# - fix
# - bugfix
commit_groups:
title_maps:
feat: Features
fix: Bug Fixes
header:
pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$"
pattern_maps:
- Type
- Scope
- Subject

notes:
keywords:
- BREAKING CHANGE
2 changes: 2 additions & 0 deletions .github/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
major_version: 1
version: 1.0.1
3 changes: 3 additions & 0 deletions .github/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
feature: ['feature/*', 'feat/*']
fix: ['fix/*', 'bugfix/*', 'hotfix/*']
chore: 'chore/*'
12 changes: 12 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
categories:
- title: 'Features'
label: 'feature'
- title: 'Bug Fixes'
label: 'fix'
- title: 'Maintenance'
label: 'chore'

template: |
## What’s Changed

$CHANGES
134 changes: 134 additions & 0 deletions .github/templates/README.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
{{- define "escape_chars" }}{{ . | strings.ReplaceAll "_" "\\_" | strings.ReplaceAll "|" "\\|" | strings.ReplaceAll "*" "\\*" }}{{- end }}
{{- define "sanatize_string" }}{{ . | strings.ReplaceAll "\n\n" "<br><br>" | strings.ReplaceAll " \n" "<br>" | strings.ReplaceAll "\n" "<br>" | tmpl.Exec "escape_chars" }}{{- end }}
{{- $action := (datasource "action") -}}{{- $meta := (datasource "meta") -}}
# {{ $action.name }}
{{ $action.description }}

## Version
v{{ $meta.version }}

# Usage
To use terraform-docs github action, configure a YAML workflow file, e.g. `.github/workflows/documentation.yml`, with the following:
```yaml
name: Generate terraform docs
on:
- pull_request
jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: {{"${{"}} github.event.pull_request.head.ref {{"}}"}}

- name: Render terraform docs inside the USAGE.md and push changes back to PR branch
uses: Dirrk/terraform-docs@v{{ $meta.major_version }}
with:
tf_docs_working_dir: .
tf_docs_output_file: USAGE.md
tf_docs_output_method: inject
tf_docs_git_push: 'true'
```
| WARNING: If USAGE.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. |
| --- |

# Configuration

## Inputs

| Name | Description | Default | Required |
|------|-------------|---------|----------|
{{- range $key, $input := $action.inputs }}
| {{ tmpl.Exec "escape_chars" $key }} | {{ if (has $input "description") }}{{ tmpl.Exec "sanatize_string" $input.description }}{{ else }}{{ tmpl.Exec "escape_chars" $key }}{{ end }} | {{ if (has $input "default") }}{{ tmpl.Exec "sanatize_string" $input.default }}{{ else }}N/A{{ end }} | {{ if (has $input "required") }}{{ $input.required }}{{ else }}false{{ end }} |
{{- end }}

## Outputs

| Name | Description |
|------|-------------|
{{- range $key, $output := $action.outputs }}
| {{ tmpl.Exec "escape_chars" $key }} | {{ if (has $output "description") }}{{ tmpl.Exec "sanatize_string" $output.description }}{{ else }}{{ tmpl.Exec "escape_chars" $key }}{{ end }} |
{{- end }}

# Important Notes

In addition to the below notes, further documentation on terraform-docs can be found [here](https://github.com/segmentio/terraform-docs)

## Output Method (tf\_docs\_output\_method)

### print
This will just print the generated file

### replace
This will create/replace the tf\_docs\_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 fail for the given module. If the file doesn't exist, it will create it using the value tf\_docs\_template which MUST have the delimeters.

## Auto commit changes
To enable you need to ensure a few things first:
- set tf\_docs\_git\_push to 'true'
- use actions/checkout@v2 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@v2
with:
ref: {{"${{"}} github.event.pull_request.head.ref {{"}}"}}
```

### Push
```
on:
push:
branches:
- master
jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: master
```

## Content type (tf\_docs\_content\_type)
- document - long form document
- table - github formatted table
- json - pure json output


# Examples

## Simple / Single folder
```
- name: Generate TF Docs
uses: Dirrk/terraform-docs@v{{ $meta.major_version }}
with:
tf_docs_working_dir: .
tf_docs_output_file: README.md
```

## Use atlantis.yaml v3 to find all dirs
```
- name: Generate TF docs
uses: Dirrk/terraform-docs@v{{ $meta.major_version }}
with:
tf_docs_atlantis_file: atlantis.yaml
```

## Find all .tf file folders under a given directory
```
- name: Generate TF docs
uses: Dirrk/terraform-docs@v{{ $meta.major_version }}
with:
tf_docs_find_dir: examples/
```

Complete examples can be found [here](https://github.com/Dirrk/terraform-docs/tree/v{{ $meta.major_version }}/examples)
14 changes: 14 additions & 0 deletions .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: PR Labeler
on:
pull_request:
types: [opened]

jobs:
pr-labeler:
runs-on: ubuntu-latest
steps:
- uses: TimonVS/pr-labeler-action@v3
with:
configuration-path: .github/pr-labeler.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16 changes: 16 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Pre-Release
on:
- pull_request
jobs:
release:
if: startsWith(github.event.pull_request.head.ref, 'release')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: Generate files for release
uses: ./
with:
entrypoint: "/generate-readme.sh"
11 changes: 6 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Changelog
<a name="unreleased"></a>
## [Unreleased]

## v1
- Backwards compatible tag for v1.X.X

### v1.0.0
- initial release
<a name="v1.0.1"></a>
## v1.0.1 - 2020-01-04

[Unreleased]: https://github.com/Dirrk/terraform-docs/compare/v1.0.1...HEAD
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM derekrada/terraform-docs-action:latest
FROM derekrada/terraform-docs:v1.0.1
COPY ./src/common.sh /common.sh
COPY ./src/docker-entrypoint.sh /docker-entrypoint.sh
COPY ./src/generate-readme.sh /generate-readme.sh
COPY ./src/default.tpl /default_template.tpl

ENTRYPOINT ["/docker-entrypoint.sh"]
Loading