Skip to content

Commit fde10e4

Browse files
fix(ci): make the git wrapper setup safe to run twice in one job
A second run resolved git to the wrapper from the first run, so the new wrapper executed itself and every later git call hung. The deploy consumer job runs the action twice and was cancelled at its timeout on every run. Resolve git with the wrapper directory removed from PATH.
1 parent 23ca117 commit fde10e4

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎.github/actions/setup-git-for-yarn/action.yml‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@ runs:
1414
WRAPPER_DIR="${RUNNER_TEMP:-/tmp}/git-clean-bin"
1515
SAFE_HOME="${SAFE_TMP}/git-clean-home"
1616
SAFE_XDG_CONFIG_HOME="${SAFE_TMP}/git-clean-xdg-config"
17-
REAL_GIT="$(command -v git)"
17+
# A job may run this action more than once. Resolve git without the
18+
# wrapper directory, or the second run points the wrapper at itself and
19+
# every later git call loops forever.
20+
CLEAN_PATH=":${PATH}:"
21+
while [[ "$CLEAN_PATH" == *":${WRAPPER_DIR}:"* ]]; do
22+
CLEAN_PATH="${CLEAN_PATH//:${WRAPPER_DIR}:/:}"
23+
done
24+
CLEAN_PATH="${CLEAN_PATH#:}"
25+
CLEAN_PATH="${CLEAN_PATH%:}"
26+
REAL_GIT="$(PATH="$CLEAN_PATH" command -v git)"
1827
1928
mkdir -p "$WRAPPER_DIR" "$SAFE_HOME" "$SAFE_XDG_CONFIG_HOME"
2029
printf '%s\n' \

0 commit comments

Comments
 (0)