From a29d521d9dd0700821e34c6e4c6c14eb621c2249 Mon Sep 17 00:00:00 2001 From: Joshua Clayton Date: Mon, 5 Jan 2026 10:20:37 -0700 Subject: [PATCH] fix: set git.user even on install only Install-only doesn't run cog.sh, so subsequent cog commands can fail, due to git.user.name and git.user.email not being set. So we move the setting to install.sh. Also make the setting conditional, so that if there is already a valid git user set up, we don't override it. --- action.yml | 5 +++-- cog.sh | 13 +++---------- install.sh | 10 ++++++++++ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/action.yml b/action.yml index c40d304..71363ca 100644 --- a/action.yml +++ b/action.yml @@ -46,6 +46,9 @@ runs: shell: bash - id: install + env: + GIT_USER: ${{ inputs.git-user }} + GIT_USER_EMAIL: ${{ inputs.git-user-email }} run: ${GITHUB_ACTION_PATH}/install.sh shell: bash @@ -62,7 +65,5 @@ runs: if: ${{ inputs.install-only != 'true' }} run: | ${GITHUB_ACTION_PATH}/cog.sh \ - "${{ inputs.git-user }}" \ - "${{ inputs.git-user-email }}" \ "${{ inputs.command }}" \ "${{ inputs.args }}" diff --git a/cog.sh b/cog.sh index f56f06a..1187d15 100755 --- a/cog.sh +++ b/cog.sh @@ -2,16 +2,9 @@ set -a -GIT_USER="${1}" -GIT_USER_EMAIL="${2}" -COMMAND="${3}" -ARGS="${4}" - -echo "Setting git user : ${GIT_USER}" -git config --global user.name "${GIT_USER}" - -echo "Setting git user email ${GIT_USER_EMAIL}" -git config --global user.email "${GIT_USER_EMAIL}" +COMMAND="${1}" +shift +ARGS="${*}" cog --version diff --git a/install.sh b/install.sh index d5745ee..646e610 100755 --- a/install.sh +++ b/install.sh @@ -45,3 +45,13 @@ else tar --strip-components=1 -xzf $TAR "$ARCH-$PLATFORM/cog" fi cd "$CUR_DIR" || exit + +if ! git config --get user.name; then + echo "Setting git user : ${GIT_USER}" + git config --global user.name "${GIT_USER}" +fi + +if ! git config --get user.email; then + echo "Setting git email : ${GIT_USER_EMAIL}" + git config --global user.email "${GIT_USER_EMAIL}" +fi