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 3, 2024
1 parent 72ed18e commit c0ae124
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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 c0ae124

Please sign in to comment.