diff --git a/.github/workflows/kdevops.yml b/.github/workflows/kdevops.yml index ac2ac6251..36805d18c 100644 --- a/.github/workflows/kdevops.yml +++ b/.github/workflows/kdevops.yml @@ -7,10 +7,11 @@ on: - cron: '0 14 * * *' # Daily at 2 PM UTC push: branches: - - '**' + - main + - 'ci-testing/**' pull_request: branches: - - '**' + - main workflow_dispatch: inputs: ci_workflow: @@ -184,26 +185,57 @@ jobs: # Repo exists - clean and update (like actions/checkout) git clean -ffdx git reset --hard HEAD - # Ensure correct remote URL - git remote set-url origin $GITHUB_SERVER_URL/$GITHUB_REPOSITORY - git fetch --depth=1 origin ${{ github.ref_name }} - git reset --hard FETCH_HEAD + # Ensure correct remote URL for public repo + git remote set-url origin ${{ github.server_url }}/${{ github.repository }}.git + + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + # For PRs, fetch the specific PR ref that GitHub creates + git fetch --depth=1 origin refs/pull/${{ github.event.number }}/head:pr-branch + git checkout pr-branch + else + # For push/schedule/workflow_dispatch, use the commit SHA directly + git fetch --depth=1 origin ${{ github.sha }} + git checkout ${{ github.sha }} + fi else # No repo - fresh clone with local mirror optimization if [[ -f "/mirror/kdevops.git/HEAD" ]]; then git clone --verbose --progress \ --reference /mirror/kdevops.git \ --depth=1 \ - --branch ${{ github.ref_name }} \ - $GITHUB_SERVER_URL/$GITHUB_REPOSITORY . + ${{ github.server_url }}/${{ github.repository }}.git . else git clone --verbose --progress \ --depth=1 \ - --branch ${{ github.ref_name }} \ - $GITHUB_SERVER_URL/$GITHUB_REPOSITORY . + ${{ github.server_url }}/${{ github.repository }}.git . + fi + + # Checkout the specific commit + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + git fetch --depth=1 origin refs/pull/${{ github.event.number }}/head:pr-branch + git checkout pr-branch + else + git checkout ${{ github.sha }} fi fi + - name: Report kdevops commit information + shell: bash + run: | + set -euxo pipefail + + # Get current commit info + commit_sha=$(git rev-parse HEAD) + commit_short=$(git rev-parse --short HEAD) + commit_subject=$(git log -1 --pretty=format:"%s") + + # Report the kdevops version used + echo "::notice title=kdevops Commit::Using kdevops commit $commit_short ($commit_sha): $commit_subject" + + # Also show in regular output for logs + echo "✅ Running kdevops CI with commit: $commit_short" + echo "📝 Commit message: $commit_subject" + - name: Configure kdevops uses: ./.github/actions/configure with: