From 022b814f93784d934a2d6d1cdb29b94714c0e636 Mon Sep 17 00:00:00 2001 From: ChristophShyper <45788587+ChristophShyper@users.noreply.github.com> Date: Sat, 6 Jun 2026 15:41:03 +0200 Subject: [PATCH 1/8] feat: allow overriding commit identity Add optional user_name and user_email inputs so workflows can control git commit identity while preserving the current actor-based defaults. Update local tests and README examples to cover the new override behavior. --- README.md | 22 ++++++++++++++++++++++ action.yml | 8 ++++++++ entrypoint.sh | 6 ++++-- tests/docker/local-image.yml | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e86c8ca..9873d01 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,8 @@ This action supports three tag levels for flexible versioning: amend: false commit_prefix: "[AUTO]" commit_message: "Automatic commit" + user_name: "" + user_email: "" signing_mode: "" signing_key: "" signing_passphrase: "" @@ -79,6 +81,8 @@ This action supports three tag levels for flexible versioning: | `amend` | No | `false` | Whether to make an amendment to the previous commit (`--amend`). Can be combined with `commit_message` to change the commit message. | | `commit_prefix` | No | `""` | Prefix added to commit message. Combines with `commit_message`. | | `commit_message` | No | `""` | Commit message to set. Combines with `commit_prefix`. Can be used with `amend` to change the commit message. | +| `user_name` | No | `""` | Git `user.name` used for created commits. Defaults to `${{ github.actor }}` when empty. | +| `user_email` | No | `""` | Git `user.email` used for created commits. Defaults to `${{ github.actor }}@users.noreply.` when empty. | | `signing_mode` | No | `""` | Commit signing mode. Supported values are `gpg` and `ssh`. Leave empty to disable signing. | | `signing_key` | No | `""` | Signing key material. For `gpg`, provide an ASCII-armored private key export. For `ssh`, provide a private key in OpenSSH or PEM format. | | `signing_passphrase` | No | `""` | Optional passphrase for the signing key. Passphrase-protected GPG keys are supported. Encrypted SSH signing keys are rejected in the current runtime. | @@ -222,6 +226,24 @@ jobs: commit_message: "Update README" ``` +### 👤 Custom commit identity example +Override the git author/committer identity used by the action. + +```yaml +- name: Commit and push with custom identity + uses: devops-infra/action-commit-push@v1.4.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + commit_message: "test(commit-push): custom identity" + user_name: "Release Automation" + user_email: "release-bot@example.com" +``` + +When `user_name` and `user_email` are empty, the action defaults to: + +- `user.name = ${{ github.actor }}` +- `user.email = ${{ github.actor }}@users.noreply.` + ## 🔏 Commit Signing This action can sign generated commits by configuring repository-local git signing settings at runtime. diff --git a/action.yml b/action.yml index 23f8bbc..8eb8a27 100644 --- a/action.yml +++ b/action.yml @@ -22,6 +22,14 @@ inputs: description: Commit message to set required: false default: "" + user_name: + description: Git user.name to use for created commits. Defaults to GITHUB_ACTOR when empty. + required: false + default: "" + user_email: + description: Git user.email to use for created commits. Defaults to GITHUB_ACTOR@users.noreply. when empty. + required: false + default: "" signing_mode: description: Commit signing mode. Supported values are gpg and ssh. required: false diff --git a/entrypoint.sh b/entrypoint.sh index ee3e62e..11ec96c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,6 +10,8 @@ echo " add_timestamp: ${INPUT_ADD_TIMESTAMP}" echo " amend: ${INPUT_AMEND}" echo " commit_prefix: ${INPUT_COMMIT_PREFIX}" echo " commit_message: ${INPUT_COMMIT_MESSAGE}" +echo " user_name: ${INPUT_USER_NAME}" +echo " user_email: ${INPUT_USER_EMAIL}" echo " signing_mode: ${INPUT_SIGNING_MODE}" echo " force: ${INPUT_FORCE}" echo " force_with_lease: ${INPUT_FORCE_WITH_LEASE}" @@ -242,8 +244,8 @@ echo "[INFO] Using repository path: ${REPO_DIR}" # Set git credentials git -C "${REPO_DIR}" remote set-url origin "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@${INPUT_ORGANIZATION_DOMAIN}/${GITHUB_REPOSITORY}" -git -C "${REPO_DIR}" config user.name "${GITHUB_ACTOR}" -git -C "${REPO_DIR}" config user.email "${GITHUB_ACTOR}@users.noreply.${INPUT_ORGANIZATION_DOMAIN}" +git -C "${REPO_DIR}" config user.name "${INPUT_USER_NAME:-${GITHUB_ACTOR}}" +git -C "${REPO_DIR}" config user.email "${INPUT_USER_EMAIL:-${GITHUB_ACTOR}@users.noreply.${INPUT_ORGANIZATION_DOMAIN}}" setup_commit_signing cd "${REPO_DIR}" diff --git a/tests/docker/local-image.yml b/tests/docker/local-image.yml index f723910..28db931 100644 --- a/tests/docker/local-image.yml +++ b/tests/docker/local-image.yml @@ -134,6 +134,42 @@ commandTests: git -C /tmp/ws config gpg.format ssh git -C /tmp/ws config gpg.ssh.allowedSignersFile /tmp/allowed_signers git -C /tmp/ws verify-commit HEAD + + - name: Entrypoint overrides commit identity + command: bash + args: + - -lc + - | + set -euo pipefail + rm -rf /tmp/ws /tmp/remote.git /tmp/github_output.txt + mkdir -p /tmp/ws + git init /tmp/ws + git -C /tmp/ws config user.name test + git -C /tmp/ws config user.email test@example.com + touch /tmp/ws/.keep + git -C /tmp/ws add . + git -C /tmp/ws commit -m init + git init --bare /tmp/remote.git + git -C /tmp/ws remote add origin /tmp/remote.git + echo "identity override" > /tmp/ws/e2e-identity.txt + GITHUB_WORKSPACE=/tmp/ws \ + GITHUB_ACTOR=tester \ + GITHUB_REPOSITORY=owner/repo \ + GITHUB_OUTPUT=/tmp/github_output.txt \ + GITHUB_TOKEN=fake \ + INPUT_ORGANIZATION_DOMAIN=github.com \ + INPUT_REPOSITORY_PATH=. \ + INPUT_AMEND=false \ + INPUT_ALLOW_EMPTY_COMMIT=false \ + INPUT_TARGET_BRANCH='' \ + INPUT_COMMIT_MESSAGE='identity override commit' \ + INPUT_USER_NAME='Release Automation' \ + INPUT_USER_EMAIL='release-bot@example.com' \ + /entrypoint.sh + test "$(git -C /tmp/ws log -1 --format=%an)" = "Release Automation" + test "$(git -C /tmp/ws log -1 --format=%ae)" = "release-bot@example.com" + test "$(git -C /tmp/ws log -1 --format=%cn)" = "Release Automation" + test "$(git -C /tmp/ws log -1 --format=%ce)" = "release-bot@example.com" fileExistenceTests: - name: entrypoint exists path: /entrypoint.sh From 254f59a41d28044347fe015378dd4d3bd6010193 Mon Sep 17 00:00:00 2001 From: ChristophShyper <45788587+ChristophShyper@users.noreply.github.com> Date: Sat, 6 Jun 2026 15:50:31 +0200 Subject: [PATCH 2/8] fix: git creds test --- tests/docker/local-image.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/docker/local-image.yml b/tests/docker/local-image.yml index 28db931..8863eb3 100644 --- a/tests/docker/local-image.yml +++ b/tests/docker/local-image.yml @@ -152,6 +152,7 @@ commandTests: git init --bare /tmp/remote.git git -C /tmp/ws remote add origin /tmp/remote.git echo "identity override" > /tmp/ws/e2e-identity.txt + set +e GITHUB_WORKSPACE=/tmp/ws \ GITHUB_ACTOR=tester \ GITHUB_REPOSITORY=owner/repo \ @@ -166,6 +167,9 @@ commandTests: INPUT_USER_NAME='Release Automation' \ INPUT_USER_EMAIL='release-bot@example.com' \ /entrypoint.sh + rc=$? + set -e + test "$rc" -ne 0 test "$(git -C /tmp/ws log -1 --format=%an)" = "Release Automation" test "$(git -C /tmp/ws log -1 --format=%ae)" = "release-bot@example.com" test "$(git -C /tmp/ws log -1 --format=%cn)" = "Release Automation" From 4117ab54aca4cbf3a81188a20e459ca28b434002 Mon Sep 17 00:00:00 2001 From: ChristophShyper <45788587+ChristophShyper@users.noreply.github.com> Date: Sat, 6 Jun 2026 16:17:37 +0200 Subject: [PATCH 3/8] feat: add ref action-commit-push tests --- tests/docker/local-image.yml | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/tests/docker/local-image.yml b/tests/docker/local-image.yml index 8863eb3..dfec468 100644 --- a/tests/docker/local-image.yml +++ b/tests/docker/local-image.yml @@ -153,21 +153,24 @@ commandTests: git -C /tmp/ws remote add origin /tmp/remote.git echo "identity override" > /tmp/ws/e2e-identity.txt set +e - GITHUB_WORKSPACE=/tmp/ws \ - GITHUB_ACTOR=tester \ - GITHUB_REPOSITORY=owner/repo \ - GITHUB_OUTPUT=/tmp/github_output.txt \ - GITHUB_TOKEN=fake \ - INPUT_ORGANIZATION_DOMAIN=github.com \ - INPUT_REPOSITORY_PATH=. \ - INPUT_AMEND=false \ - INPUT_ALLOW_EMPTY_COMMIT=false \ - INPUT_TARGET_BRANCH='' \ - INPUT_COMMIT_MESSAGE='identity override commit' \ - INPUT_USER_NAME='Release Automation' \ - INPUT_USER_EMAIL='release-bot@example.com' \ - /entrypoint.sh - rc=$? + if GITHUB_WORKSPACE=/tmp/ws \ + GITHUB_ACTOR=tester \ + GITHUB_REPOSITORY=owner/repo \ + GITHUB_OUTPUT=/tmp/github_output.txt \ + GITHUB_TOKEN=fake \ + INPUT_ORGANIZATION_DOMAIN=github.com \ + INPUT_REPOSITORY_PATH=. \ + INPUT_AMEND=false \ + INPUT_ALLOW_EMPTY_COMMIT=false \ + INPUT_TARGET_BRANCH='' \ + INPUT_COMMIT_MESSAGE='identity override commit' \ + INPUT_USER_NAME='Release Automation' \ + INPUT_USER_EMAIL='release-bot@example.com' \ + /entrypoint.sh; then + rc=0 + else + rc=$? + fi set -e test "$rc" -ne 0 test "$(git -C /tmp/ws log -1 --format=%an)" = "Release Automation" From 0c48be752377617b55ff106572c4856921a218bf Mon Sep 17 00:00:00 2001 From: ChristophShyper <45788587+ChristophShyper@users.noreply.github.com> Date: Sat, 6 Jun 2026 16:28:03 +0200 Subject: [PATCH 4/8] fix: update tests --- tests/docker/local-image.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/docker/local-image.yml b/tests/docker/local-image.yml index dfec468..b184f75 100644 --- a/tests/docker/local-image.yml +++ b/tests/docker/local-image.yml @@ -153,7 +153,8 @@ commandTests: git -C /tmp/ws remote add origin /tmp/remote.git echo "identity override" > /tmp/ws/e2e-identity.txt set +e - if GITHUB_WORKSPACE=/tmp/ws \ + rc=0 + GITHUB_WORKSPACE=/tmp/ws \ GITHUB_ACTOR=tester \ GITHUB_REPOSITORY=owner/repo \ GITHUB_OUTPUT=/tmp/github_output.txt \ @@ -166,11 +167,7 @@ commandTests: INPUT_COMMIT_MESSAGE='identity override commit' \ INPUT_USER_NAME='Release Automation' \ INPUT_USER_EMAIL='release-bot@example.com' \ - /entrypoint.sh; then - rc=0 - else - rc=$? - fi + /entrypoint.sh || rc=$? set -e test "$rc" -ne 0 test "$(git -C /tmp/ws log -1 --format=%an)" = "Release Automation" From 539b566741021242a471932e18901b07a0c9df9b Mon Sep 17 00:00:00 2001 From: ChristophShyper <45788587+ChristophShyper@users.noreply.github.com> Date: Sat, 6 Jun 2026 16:47:16 +0200 Subject: [PATCH 5/8] fix: update tests --- tests/docker/local-image.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/docker/local-image.yml b/tests/docker/local-image.yml index b184f75..fda8d0f 100644 --- a/tests/docker/local-image.yml +++ b/tests/docker/local-image.yml @@ -152,22 +152,22 @@ commandTests: git init --bare /tmp/remote.git git -C /tmp/ws remote add origin /tmp/remote.git echo "identity override" > /tmp/ws/e2e-identity.txt + export GITHUB_WORKSPACE=/tmp/ws + export GITHUB_ACTOR=tester + export GITHUB_REPOSITORY=owner/repo + export GITHUB_OUTPUT=/tmp/github_output.txt + export GITHUB_TOKEN=fake + export INPUT_ORGANIZATION_DOMAIN=github.com + export INPUT_REPOSITORY_PATH=. + export INPUT_AMEND=false + export INPUT_ALLOW_EMPTY_COMMIT=false + export INPUT_TARGET_BRANCH='' + export INPUT_COMMIT_MESSAGE='identity override commit' + export INPUT_USER_NAME='Release Automation' + export INPUT_USER_EMAIL='release-bot@example.com' set +e - rc=0 - GITHUB_WORKSPACE=/tmp/ws \ - GITHUB_ACTOR=tester \ - GITHUB_REPOSITORY=owner/repo \ - GITHUB_OUTPUT=/tmp/github_output.txt \ - GITHUB_TOKEN=fake \ - INPUT_ORGANIZATION_DOMAIN=github.com \ - INPUT_REPOSITORY_PATH=. \ - INPUT_AMEND=false \ - INPUT_ALLOW_EMPTY_COMMIT=false \ - INPUT_TARGET_BRANCH='' \ - INPUT_COMMIT_MESSAGE='identity override commit' \ - INPUT_USER_NAME='Release Automation' \ - INPUT_USER_EMAIL='release-bot@example.com' \ - /entrypoint.sh || rc=$? + /entrypoint.sh + rc=$? set -e test "$rc" -ne 0 test "$(git -C /tmp/ws log -1 --format=%an)" = "Release Automation" From 7027c20c8fe850502f5d4bf3f5b390d4e7c4956a Mon Sep 17 00:00:00 2001 From: ChristophShyper <45788587+ChristophShyper@users.noreply.github.com> Date: Sat, 6 Jun 2026 17:04:51 +0200 Subject: [PATCH 6/8] fix: action-commit-push again --- entrypoint.sh | 4 ++++ tests/docker/local-image.yml | 15 +++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 11ec96c..4832355 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -246,6 +246,10 @@ echo "[INFO] Using repository path: ${REPO_DIR}" git -C "${REPO_DIR}" remote set-url origin "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@${INPUT_ORGANIZATION_DOMAIN}/${GITHUB_REPOSITORY}" git -C "${REPO_DIR}" config user.name "${INPUT_USER_NAME:-${GITHUB_ACTOR}}" git -C "${REPO_DIR}" config user.email "${INPUT_USER_EMAIL:-${GITHUB_ACTOR}@users.noreply.${INPUT_ORGANIZATION_DOMAIN}}" +export GIT_AUTHOR_NAME="${INPUT_USER_NAME:-${GITHUB_ACTOR}}" +export GIT_AUTHOR_EMAIL="${INPUT_USER_EMAIL:-${GITHUB_ACTOR}@users.noreply.${INPUT_ORGANIZATION_DOMAIN}}" +export GIT_COMMITTER_NAME="${INPUT_USER_NAME:-${GITHUB_ACTOR}}" +export GIT_COMMITTER_EMAIL="${INPUT_USER_EMAIL:-${GITHUB_ACTOR}@users.noreply.${INPUT_ORGANIZATION_DOMAIN}}" setup_commit_signing cd "${REPO_DIR}" diff --git a/tests/docker/local-image.yml b/tests/docker/local-image.yml index fda8d0f..7af18b3 100644 --- a/tests/docker/local-image.yml +++ b/tests/docker/local-image.yml @@ -152,6 +152,17 @@ commandTests: git init --bare /tmp/remote.git git -C /tmp/ws remote add origin /tmp/remote.git echo "identity override" > /tmp/ws/e2e-identity.txt + real_git="$(command -v git)" + mkdir -p /tmp/fakebin + cat > /tmp/fakebin/git < Date: Sat, 6 Jun 2026 17:12:18 +0200 Subject: [PATCH 7/8] fix: action-commit-push again --- tests/docker/local-image.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/docker/local-image.yml b/tests/docker/local-image.yml index 7af18b3..ac91a53 100644 --- a/tests/docker/local-image.yml +++ b/tests/docker/local-image.yml @@ -154,13 +154,12 @@ commandTests: echo "identity override" > /tmp/ws/e2e-identity.txt real_git="$(command -v git)" mkdir -p /tmp/fakebin - cat > /tmp/fakebin/git < /tmp/fakebin/git chmod +x /tmp/fakebin/git export PATH="/tmp/fakebin:${PATH}" export GITHUB_WORKSPACE=/tmp/ws From 01408777f8d911e5cd3ff851d72ef999310e7c45 Mon Sep 17 00:00:00 2001 From: ChristophShyper <45788587+ChristophShyper@users.noreply.github.com> Date: Sat, 6 Jun 2026 19:20:15 +0200 Subject: [PATCH 8/8] fix: action-commit-push again --- tests/docker/local-image.yml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/tests/docker/local-image.yml b/tests/docker/local-image.yml index ac91a53..7e80be2 100644 --- a/tests/docker/local-image.yml +++ b/tests/docker/local-image.yml @@ -152,16 +152,6 @@ commandTests: git init --bare /tmp/remote.git git -C /tmp/ws remote add origin /tmp/remote.git echo "identity override" > /tmp/ws/e2e-identity.txt - real_git="$(command -v git)" - mkdir -p /tmp/fakebin - printf '%s\n' \ - '#!/bin/sh' \ - 'if [ "$1" = "push" ]; then' \ - ' exit 0' \ - 'fi' \ - "exec ${real_git} \"\$@\"" > /tmp/fakebin/git - chmod +x /tmp/fakebin/git - export PATH="/tmp/fakebin:${PATH}" export GITHUB_WORKSPACE=/tmp/ws export GITHUB_ACTOR=tester export GITHUB_REPOSITORY=owner/repo @@ -175,7 +165,7 @@ commandTests: export INPUT_COMMIT_MESSAGE='identity override commit' export INPUT_USER_NAME='Release Automation' export INPUT_USER_EMAIL='release-bot@example.com' - /entrypoint.sh + /entrypoint.sh || true test "$(git -C /tmp/ws log -1 --format=%an)" = "Release Automation" test "$(git -C /tmp/ws log -1 --format=%ae)" = "release-bot@example.com" test "$(git -C /tmp/ws log -1 --format=%cn)" = "Release Automation"