diff --git a/action.yml b/action.yml index 4944994..0b0c06f 100644 --- a/action.yml +++ b/action.yml @@ -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 @@ -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 }} @@ -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 diff --git a/src/docker-entrypoint.sh b/src/docker-entrypoint.sh index d9a61a0..6c87666 100755 --- a/src/docker-entrypoint.sh +++ b/src/docker-entrypoint.sh @@ -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}"