|
35 | 35 | shell: bash |
36 | 36 | run: | |
37 | 37 | set -euo pipefail |
38 | | - git config --global --add safe.directory "$GITHUB_WORKSPACE" |
| 38 | + # Trust only this workspace. If the default global config is not writable, |
| 39 | + # use a temporary global config file and persist it for subsequent steps. |
| 40 | + if ! git config --global --add safe.directory "$GITHUB_WORKSPACE" >/dev/null 2>&1; then |
| 41 | + if [[ -n "${RUNNER_TEMP:-}" ]]; then |
| 42 | + SAFE_GLOBAL="${RUNNER_TEMP}/gitcoverage-global.gitconfig" |
| 43 | + else |
| 44 | + SAFE_GLOBAL="${GITHUB_WORKSPACE}/.gitcoverage-global.gitconfig" |
| 45 | + fi |
| 46 | + touch "$SAFE_GLOBAL" |
| 47 | + export GIT_CONFIG_GLOBAL="$SAFE_GLOBAL" |
| 48 | + echo "GIT_CONFIG_GLOBAL=$SAFE_GLOBAL" >> "$GITHUB_ENV" |
| 49 | + if ! git config --global --add safe.directory "$GITHUB_WORKSPACE"; then |
| 50 | + echo "Failed to configure safe.directory for '$GITHUB_WORKSPACE'." >&2 |
| 51 | + exit 1 |
| 52 | + fi |
| 53 | + fi |
39 | 54 | git config --local user.email "action@github.com" |
40 | 55 | git config --local user.name "GitHub Action" |
41 | 56 |
|
@@ -261,7 +276,7 @@ runs: |
261 | 276 | git rm -rf --cached . >/dev/null 2>&1 || true |
262 | 277 | echo '# Coverage branch' > README.md |
263 | 278 | git add README.md |
264 | | - git commit -m 'Add README.md' |
| 279 | + git -c commit.gpgsign=false commit -m 'Add README.md' |
265 | 280 | # Push with auth via checkout action's token/remote config. |
266 | 281 | # If another concurrent run creates 'coverage' first, treat that as success. |
267 | 282 | if git push origin coverage; then |
@@ -472,7 +487,7 @@ runs: |
472 | 487 | git add -A -- "${BRANCH}" |
473 | 488 | # Only proceed when this step actually staged changes for the target path. |
474 | 489 | if ! git diff --cached --quiet -- "${BRANCH}"; then |
475 | | - git commit -m "update" |
| 490 | + git -c commit.gpgsign=false commit -m "update" |
476 | 491 |
|
477 | 492 | max_attempts=5 |
478 | 493 | attempt=1 |
|
0 commit comments