Skip to content

Commit

Permalink
Adding git-sub-dir
Browse files Browse the repository at this point in the history
Signed-off-by: Timothy Clarke <Timothy.Clarke@ServerBox.co.uk>
  • Loading branch information
timothy authored and timothyclarke committed Sep 9, 2024
1 parent 72ed18e commit 46b135f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ branch.

## Version

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

### Upgrade v0 to v1
Expand Down Expand Up @@ -42,7 +42,7 @@ jobs:
ref: ${{ github.event.pull_request.head.ref }}

- name: Render terraform docs inside the README.md and push changes back to PR branch
uses: terraform-docs/gh-actions@v1.2.0
uses: terraform-docs/gh-actions@v1.2.1
with:
working-dir: .
output-file: README.md
Expand Down Expand Up @@ -72,6 +72,7 @@ jobs:
| git-push-sign-off | If true it will sign-off commit | `false` | false |
| 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 |
| git-push-user-name | If empty the name of the GitHub Actions bot will be used (i.e. `github-actions[bot]`) | `""` | false |
| git-sub-dir | Name of subdirectory if checkout `path` option is used (i.e. `modules`) | `""` | false |
| indention | Indention level of Markdown sections [1, 2, 3, 4, 5] | `2` | false |
| output-file | File in module directory where the docs should be placed | `README.md` | false |
| 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 |
Expand Down Expand Up @@ -147,7 +148,7 @@ To enable you need to ensure a few things first:

```yaml
- name: Generate TF Docs
uses: terraform-docs/gh-actions@v1.2.0
uses: terraform-docs/gh-actions@v1.2.1
with:
working-dir: .
```
Expand All @@ -156,7 +157,7 @@ To enable you need to ensure a few things first:

```yaml
- name: Generate TF Docs
uses: terraform-docs/gh-actions@v1.2.0
uses: terraform-docs/gh-actions@v1.2.1
with:
working-dir: .,example1,example3/modules/test
```
Expand All @@ -165,7 +166,7 @@ To enable you need to ensure a few things first:

```yaml
- name: Generate TF docs
uses: terraform-docs/gh-actions@v1.2.0
uses: terraform-docs/gh-actions@v1.2.1
with:
atlantis-file: atlantis.yaml
```
Expand All @@ -174,7 +175,7 @@ To enable you need to ensure a few things first:

```yaml
- name: Generate TF docs
uses: terraform-docs/gh-actions@v1.2.0
uses: terraform-docs/gh-actions@v1.2.1
with:
find-dir: examples/
```
Expand All @@ -183,13 +184,13 @@ To enable you need to ensure a few things first:

```yaml
- name: Generate TF docs
uses: terraform-docs/gh-actions@v1.2.0
uses: terraform-docs/gh-actions@v1.2.1
with:
working-dir: examples/
recursive: true
recursive-path: modules
```

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

[terraform-docs]: https://github.com/terraform-docs/terraform-docs
7 changes: 6 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ inputs:
description: If true it will sign-off commit
required: false
default: "false"
git-sub-dir:
description: Subdirectory that terraform code is checked out into
required: false
default: ""
fail-on-diff:
description: Fail the job if there is any diff found between the generated output and existing file (ignored if `git-push` is set)
required: false
Expand All @@ -85,7 +89,7 @@ outputs:

runs:
using: docker
image: "docker://quay.io/terraform-docs/gh-actions:1.2.0"
image: "docker://quay.io/terraform-docs/gh-actions:1.2.1"
env:
INPUT_WORKING_DIR: ${{ inputs.working-dir }}
INPUT_ATLANTIS_FILE: ${{ inputs.atlantis-file }}
Expand All @@ -105,6 +109,7 @@ runs:
INPUT_GIT_PUSH_SIGN_OFF: ${{ inputs.git-push-sign-off }}
INPUT_GIT_PUSH_USER_NAME: ${{ inputs.git-push-user-name }}
INPUT_GIT_PUSH_USER_EMAIL: ${{ inputs.git-push-user-email }}
INPUT_GIT_SUB_DIR: ${{ inputs.git-sub-dir }}

branding:
icon: file-text
Expand Down
7 changes: 6 additions & 1 deletion src/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,16 @@ if [ -z "${INPUT_GIT_PUSH_USER_EMAIL}" ]; then
INPUT_GIT_PUSH_USER_EMAIL="github-actions[bot]@users.noreply.github.com"
fi

if [ -n "${INPUT_GIT_SUB_DIR}" ]; then
GITHUB_WORKSPACE="${GITHUB_WORKSPACE}/${INPUT_GIT_SUB_DIR}"
echo "Using non-standard GITHUB_WORKSPACE of ${GITHUB_WORKSPACE}"
fi

git_setup() {
# When the runner maps the $GITHUB_WORKSPACE mount, it is owned by the runner
# user while the created folders are owned by the container user, causing this
# error. Issue description here: https://github.com/actions/checkout/issues/766
git config --global --add safe.directory /github/workspace
git config --global --add safe.directory "${GITHUB_WORKSPACE}"

git config --global user.name "${INPUT_GIT_PUSH_USER_NAME}"
git config --global user.email "${INPUT_GIT_PUSH_USER_EMAIL}"
Expand Down

0 comments on commit 46b135f

Please sign in to comment.