Skip to content

Commit 89278fb

Browse files
Merge pull request #138 from timothyclarke/git-sub-dir
Adding git-sub-dir
2 parents 72ed18e + 34611d2 commit 89278fb

File tree

4 files changed

+34
-12
lines changed

4 files changed

+34
-12
lines changed

CONTRIBUTING.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ first to see if there's already an issue relating to the thing you'd like to
2727
contribute. If there isn't, please raise a new one! Let us know what you'd like
2828
to work on, and why.
2929

30-
Be sure to practice [good git commit hygiene] as you make your changes. All but
30+
Be sure to practice good git commit hygiene as you make your changes. All but
3131
the smallest changes should be broken up into a few commits that tell a story.
3232
Use your git commits to provide context for the folks who will review PR, and
3333
the folks who will be spelunking the codebase in the months and years to come.
@@ -57,6 +57,17 @@ Thank you for reading through our contributing guide! We appreciate you taking
5757
the time to ensure your contributions are high quality and easy for our community
5858
to review and accept.
5959

60+
## Testing Code
61+
The [test workflow] uses [shellcheck] then [gomplate] to run [scripts/update-readme.sh].
62+
Run [shellcheck] against any shell files eg `shellcheck src/docker-entrypoint.sh`
63+
[scripts/update-readme.sh] can be run as is eg `./scripts/update-readme.sh`
64+
note the default output is `README.md updated.` so you will need to use git diff or
65+
similar to check for changes
66+
67+
6068
[Slack]: https://slack.terraform-docs.io/
61-
[good git commit hygiene]: https://www.futurelearn.com/info/blog/telling-stories-with-your-git-history
6269
[Developer Certificate of Origin]: https://github.com/apps/dco
70+
[test workflow]: https://github.com/terraform-docs/gh-actions/blob/main/.github/workflows/test.yml
71+
[shellcheck]: https://github.com/koalaman/shellcheck
72+
[gomplate]: https://github.com/hairyhenderson/gomplate/
73+
[scripts/update-readme.sh]: https://github.com/terraform-docs/gh-actions/blob/main/scripts/update-readme.sh

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ branch.
88

99
## Version
1010

11-
`v1.2.0` (uses [terraform-docs] v0.18.0, which is supported and tested on Terraform
11+
`v1.2.1` (uses [terraform-docs] v0.18.0, which is supported and tested on Terraform
1212
version 0.11+ and 0.12+ but may work for others.)
1313

1414
### Upgrade v0 to v1
@@ -42,7 +42,7 @@ jobs:
4242
ref: ${{ github.event.pull_request.head.ref }}
4343

4444
- name: Render terraform docs inside the README.md and push changes back to PR branch
45-
uses: terraform-docs/[email protected].0
45+
uses: terraform-docs/[email protected].1
4646
with:
4747
working-dir: .
4848
output-file: README.md
@@ -72,6 +72,7 @@ jobs:
7272
| git-push-sign-off | If true it will sign-off commit | `false` | false |
7373
| 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 |
7474
| git-push-user-name | If empty the name of the GitHub Actions bot will be used (i.e. `github-actions[bot]`) | `""` | false |
75+
| git-sub-dir | Subdirectory that terraform code is checked out into | `""` | false |
7576
| indention | Indention level of Markdown sections [1, 2, 3, 4, 5] | `2` | false |
7677
| output-file | File in module directory where the docs should be placed | `README.md` | false |
7778
| output-format | terraform-docs format to generate content (see [all formats](https://github.com/terraform-docs/terraform-docs/blob/master/docs/FORMATS\_GUIDE.md)) (ignored if `config-file` is set) | `markdown table` | false |
@@ -147,7 +148,7 @@ To enable you need to ensure a few things first:
147148

148149
```yaml
149150
- name: Generate TF Docs
150-
uses: terraform-docs/[email protected].0
151+
uses: terraform-docs/[email protected].1
151152
with:
152153
working-dir: .
153154
```
@@ -156,7 +157,7 @@ To enable you need to ensure a few things first:
156157

157158
```yaml
158159
- name: Generate TF Docs
159-
uses: terraform-docs/[email protected].0
160+
uses: terraform-docs/[email protected].1
160161
with:
161162
working-dir: .,example1,example3/modules/test
162163
```
@@ -165,7 +166,7 @@ To enable you need to ensure a few things first:
165166

166167
```yaml
167168
- name: Generate TF docs
168-
uses: terraform-docs/[email protected].0
169+
uses: terraform-docs/[email protected].1
169170
with:
170171
atlantis-file: atlantis.yaml
171172
```
@@ -174,7 +175,7 @@ To enable you need to ensure a few things first:
174175

175176
```yaml
176177
- name: Generate TF docs
177-
uses: terraform-docs/[email protected].0
178+
uses: terraform-docs/[email protected].1
178179
with:
179180
find-dir: examples/
180181
```
@@ -183,13 +184,13 @@ To enable you need to ensure a few things first:
183184

184185
```yaml
185186
- name: Generate TF docs
186-
uses: terraform-docs/[email protected].0
187+
uses: terraform-docs/[email protected].1
187188
with:
188189
working-dir: examples/
189190
recursive: true
190191
recursive-path: modules
191192
```
192193

193-
Complete examples can be found [here](https://github.com/terraform-docs/gh-actions/tree/v1.2.0/examples).
194+
Complete examples can be found [here](https://github.com/terraform-docs/gh-actions/tree/v1.2.1/examples).
194195

195196
[terraform-docs]: https://github.com/terraform-docs/terraform-docs

action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ inputs:
7474
description: If true it will sign-off commit
7575
required: false
7676
default: "false"
77+
git-sub-dir:
78+
description: Subdirectory that terraform code is checked out into
79+
required: false
80+
default: ""
7781
fail-on-diff:
7882
description: Fail the job if there is any diff found between the generated output and existing file (ignored if `git-push` is set)
7983
required: false
@@ -85,7 +89,7 @@ outputs:
8589

8690
runs:
8791
using: docker
88-
image: "docker://quay.io/terraform-docs/gh-actions:1.2.0"
92+
image: "docker://quay.io/terraform-docs/gh-actions:1.2.1"
8993
env:
9094
INPUT_WORKING_DIR: ${{ inputs.working-dir }}
9195
INPUT_ATLANTIS_FILE: ${{ inputs.atlantis-file }}
@@ -105,6 +109,7 @@ runs:
105109
INPUT_GIT_PUSH_SIGN_OFF: ${{ inputs.git-push-sign-off }}
106110
INPUT_GIT_PUSH_USER_NAME: ${{ inputs.git-push-user-name }}
107111
INPUT_GIT_PUSH_USER_EMAIL: ${{ inputs.git-push-user-email }}
112+
INPUT_GIT_SUB_DIR: ${{ inputs.git-sub-dir }}
108113

109114
branding:
110115
icon: file-text

src/docker-entrypoint.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,16 @@ if [ -z "${INPUT_GIT_PUSH_USER_EMAIL}" ]; then
4848
INPUT_GIT_PUSH_USER_EMAIL="github-actions[bot]@users.noreply.github.com"
4949
fi
5050

51+
if [ -n "${INPUT_GIT_SUB_DIR}" ]; then
52+
GITHUB_WORKSPACE="${GITHUB_WORKSPACE}/${INPUT_GIT_SUB_DIR}"
53+
echo "Using non-standard GITHUB_WORKSPACE of ${GITHUB_WORKSPACE}"
54+
fi
55+
5156
git_setup() {
5257
# When the runner maps the $GITHUB_WORKSPACE mount, it is owned by the runner
5358
# user while the created folders are owned by the container user, causing this
5459
# error. Issue description here: https://github.com/actions/checkout/issues/766
55-
git config --global --add safe.directory /github/workspace
60+
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
5661

5762
git config --global user.name "${INPUT_GIT_PUSH_USER_NAME}"
5863
git config --global user.email "${INPUT_GIT_PUSH_USER_EMAIL}"

0 commit comments

Comments
 (0)