From 28b97b3737b22f0cc143c06a94a50fc270fd3273 Mon Sep 17 00:00:00 2001 From: Mohammad Shafiee Date: Wed, 22 Jul 2026 15:47:18 +0200 Subject: [PATCH] fix(ci): re-init git in container if .git is missing for commit step The debian:trixie container may not have .git after checkout. Add safe.directory config and re-initialize (git init + fetch) if .git is absent, with token-based remote URL for push authentication. --- .github/workflows/publish-repo.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/publish-repo.yml b/.github/workflows/publish-repo.yml index e164fe5..04316d6 100644 --- a/.github/workflows/publish-repo.yml +++ b/.github/workflows/publish-repo.yml @@ -115,11 +115,23 @@ jobs: exit 0 - name: Commit generated indices back to main + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | set -eux cd "$GITHUB_WORKSPACE" + # In the container, .git may be missing or unsafe. Re-init if needed. + git config --global --add safe.directory '*' + if [ ! -d .git ]; then + git init -b main + git remote add origin "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" + git fetch --depth 1 origin main + git checkout -f main + fi git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + # Ensure push uses token auth. + git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" mkdir -p pool && touch pool/.gitkeep git add dists pool/.gitkeep if git diff --cached --quiet; then