File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -48,21 +48,24 @@ if [[ ! -d "${REPO_DIR}" ]]; then
4848 echo " [ERROR] Repository path does not exist: ${REPO_DIR} "
4949 exit 1
5050fi
51- if ! git -C " ${REPO_DIR} " rev-parse --is-inside-work-tree > /dev/null 2>&1 ; then
52- echo " [ERROR] Path is not a git repository: ${REPO_DIR} "
53- exit 1
54- fi
55- echo " [INFO] Using repository path: ${REPO_DIR} "
5651
5752# Keep all global git config isolated to a temp file
5853export GIT_CONFIG_GLOBAL
5954GIT_CONFIG_GLOBAL=" $( mktemp /tmp/action-commit-push-git-config-XXXXXX) "
6055trap ' rm -f "${GIT_CONFIG_GLOBAL}"' EXIT
6156
62- # Set git credentials
57+ # Configure safe directories before git repo validation
6358git config --global safe.directory " ${GITHUB_WORKSPACE} "
6459git config --global safe.directory /github/workspace
6560git config --global safe.directory " ${REPO_DIR} "
61+
62+ if ! git -C " ${REPO_DIR} " rev-parse --is-inside-work-tree > /dev/null 2>&1 ; then
63+ echo " [ERROR] Path is not a git repository: ${REPO_DIR} "
64+ exit 1
65+ fi
66+ echo " [INFO] Using repository path: ${REPO_DIR} "
67+
68+ # Set git credentials
6669git -C " ${REPO_DIR} " remote set-url origin " https://${GITHUB_ACTOR} :${GITHUB_TOKEN} @${INPUT_ORGANIZATION_DOMAIN} /${GITHUB_REPOSITORY} "
6770git -C " ${REPO_DIR} " config user.name " ${GITHUB_ACTOR} "
6871git -C " ${REPO_DIR} " config user.email " ${GITHUB_ACTOR} @users.noreply.${INPUT_ORGANIZATION_DOMAIN} "
Original file line number Diff line number Diff line change @@ -23,6 +23,34 @@ commandTests:
2323 args :
2424 - -lc
2525 - test ! -e /git-lfs*.deb
26+
27+ - name : Entrypoint handles default repository path
28+ command : bash
29+ args :
30+ - -lc
31+ - |
32+ set -e
33+ rm -rf /tmp/ws /tmp/remote.git
34+ mkdir -p /tmp/ws
35+ git init /tmp/ws
36+ git -C /tmp/ws config user.name test
37+ git -C /tmp/ws config user.email test@example.com
38+ touch /tmp/ws/.keep
39+ git -C /tmp/ws add .
40+ git -C /tmp/ws commit -m init
41+ git init --bare /tmp/remote.git
42+ git -C /tmp/ws remote add origin /tmp/remote.git
43+ GITHUB_WORKSPACE=/tmp/ws \
44+ GITHUB_ACTOR=tester \
45+ GITHUB_REPOSITORY=owner/repo \
46+ GITHUB_OUTPUT=/tmp/github_output.txt \
47+ GITHUB_TOKEN=fake \
48+ INPUT_ORGANIZATION_DOMAIN=github.com \
49+ INPUT_REPOSITORY_PATH=. \
50+ INPUT_AMEND=false \
51+ INPUT_ALLOW_EMPTY_COMMIT=false \
52+ INPUT_TARGET_BRANCH='' \
53+ /entrypoint.sh
2654fileExistenceTests :
2755 - name : entrypoint exists
2856 path : /entrypoint.sh
You can’t perform that action at this time.
0 commit comments