Skip to content

Commit 46b135f

Browse files
timothytimothyclarke
timothy
authored andcommitted
Adding git-sub-dir
Signed-off-by: Timothy Clarke <[email protected]>
1 parent 72ed18e commit 46b135f

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

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 | Name of subdirectory if checkout `path` option is used (i.e. `modules`) | `""` | 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)