Skip to content

Commit 0494a3e

Browse files
committed
github: fix self-hosted runner checkout issues
The unified workflow had two critical issues with repository checkout on self-hosted runners. For pull requests, it attempted to fetch non-existent merge refs like "35/merge". For push events, it used incomplete HTTPS URLs missing the .git suffix. This fixes both by using proper GitHub PR refs (refs/pull/N/head) and complete HTTPS clone URLs with .git suffix for the public repository. Fixes: 1b74004 ("github: unify self-hosted runner workflows") Generated-by: Claude AI Signed-off-by: Daniel Gomez <[email protected]>
1 parent 8dbe585 commit 0494a3e

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

.github/workflows/kdevops.yml

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -179,29 +179,27 @@ jobs:
179179
run: |
180180
set -euxo pipefail
181181
182-
# More efficient approach similar to actions/checkout
183-
if [[ -d ".git" ]]; then
184-
# Repo exists - clean and update (like actions/checkout)
185-
git clean -ffdx
186-
git reset --hard HEAD
187-
# Ensure correct remote URL
188-
git remote set-url origin $GITHUB_SERVER_URL/$GITHUB_REPOSITORY
189-
git fetch --depth=1 origin ${{ github.ref_name }}
190-
git reset --hard FETCH_HEAD
182+
# Start fresh
183+
rm -rfv ./* ./.* 2>/dev/null || true
184+
185+
# Clone repository (with mirror optimization when available)
186+
if [[ -f "/mirror/kdevops.git/HEAD" ]]; then
187+
git clone --verbose --progress \
188+
--reference /mirror/kdevops.git \
189+
--depth=1 \
190+
${{ github.server_url }}/${{ github.repository }}.git .
191191
else
192-
# No repo - fresh clone with local mirror optimization
193-
if [[ -f "/mirror/kdevops.git/HEAD" ]]; then
194-
git clone --verbose --progress \
195-
--reference /mirror/kdevops.git \
196-
--depth=1 \
197-
--branch ${{ github.ref_name }} \
198-
$GITHUB_SERVER_URL/$GITHUB_REPOSITORY .
199-
else
200-
git clone --verbose --progress \
201-
--depth=1 \
202-
--branch ${{ github.ref_name }} \
203-
$GITHUB_SERVER_URL/$GITHUB_REPOSITORY .
204-
fi
192+
git clone --verbose --progress \
193+
--depth=1 \
194+
${{ github.server_url }}/${{ github.repository }}.git .
195+
fi
196+
197+
# Checkout the appropriate ref based on event type
198+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
199+
git fetch --depth=1 origin refs/pull/${{ github.event.number }}/head:pr-branch
200+
git checkout pr-branch
201+
else
202+
git checkout ${{ github.sha }}
205203
fi
206204
207205
- name: Configure kdevops

0 commit comments

Comments
 (0)