diff --git a/.github/workflows/kdevops.yml b/.github/workflows/kdevops.yml index ac2ac6251..60754ba75 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: @@ -179,31 +180,46 @@ jobs: run: | set -euxo pipefail - # More efficient approach similar to actions/checkout - if [[ -d ".git" ]]; then - # 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 + # Start fresh + rm -rfv ./* ./.* 2>/dev/null || true + + # Clone repository (with mirror optimization when available) + if [[ -f "/mirror/kdevops.git/HEAD" ]]; then + git clone --verbose --progress \ + --reference /mirror/kdevops.git \ + --depth=1 \ + ${{ github.server_url }}/${{ github.repository }}.git . + else + git clone --verbose --progress \ + --depth=1 \ + ${{ github.server_url }}/${{ github.repository }}.git . + fi + + # Checkout the appropriate ref based on event type + 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 - # 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 . - else - git clone --verbose --progress \ - --depth=1 \ - --branch ${{ github.ref_name }} \ - $GITHUB_SERVER_URL/$GITHUB_REPOSITORY . - fi + git checkout ${{ github.sha }} 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: