diff --git a/.github/workflows/clp-artifact-build.yaml b/.github/workflows/clp-artifact-build.yaml index b47b0369a7..443116bb0f 100644 --- a/.github/workflows/clp-artifact-build.yaml +++ b/.github/workflows/clp-artifact-build.yaml @@ -26,14 +26,16 @@ concurrency: cancel-in-progress: "${{github.ref != 'refs/heads/main'}}" jobs: + skip-duplicate-check: + uses: "./.github/workflows/skip-duplicate-check.yaml" + filter-relevant-changes: name: "filter-relevant-changes" - runs-on: &runner >- - ${{ - github.repository_owner == 'y-scope' - && fromJSON('["self-hosted", "x64", "ubuntu-noble"]') - || 'ubuntu-24.04' - }} + needs: "skip-duplicate-check" + if: "needs.skip-duplicate-check.outputs.should_skip != 'true'" + # This job only performs git operations to detect changed paths, so we use a GitHub-hosted + # runner to avoid consuming self-hosted runner resources needed for heavier build jobs. + runs-on: "ubuntu-24.04" outputs: centos_stream_9_image_changed: "${{steps.filter.outputs.centos_stream_9_image}}" manylinux_2_28_x86_64_image_changed: "${{steps.filter.outputs.manylinux_2_28_x86_64_image}}" @@ -104,7 +106,14 @@ jobs: name: "centos-stream-9-deps-image" if: "needs.filter-relevant-changes.outputs.centos_stream_9_image_changed == 'true'" needs: "filter-relevant-changes" - runs-on: *runner + # Define a reusable runner configuration for jobs that require Docker and benefit from + # self-hosted runner resources. Falls back to GitHub-hosted runners for non-y-scope forks. + runs-on: &runner >- + ${{ + github.repository_owner == 'y-scope' + && fromJSON('["self-hosted", "x64", "ubuntu-noble"]') + || 'ubuntu-24.04' + }} steps: - uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683" with: diff --git a/.github/workflows/skip-duplicate-check.yaml b/.github/workflows/skip-duplicate-check.yaml new file mode 100644 index 0000000000..abc13c0279 --- /dev/null +++ b/.github/workflows/skip-duplicate-check.yaml @@ -0,0 +1,40 @@ +name: "skip-duplicate-check" + +# Reusable workflow to skip duplicate runs when both push and pull_request events trigger on the +# same commit. Other workflows can call this and check the `should_skip` output to avoid redundant +# work. +# +# Usage: +# jobs: +# skip-check: +# uses: "./.github/workflows/skip-duplicate-check.yaml" +# +# my-job: +# needs: "skip-check" +# if: "needs.skip-check.outputs.should_skip != 'true'" +# ... + +on: + workflow_call: + outputs: + should_skip: + description: "Whether the workflow run should be skipped" + value: "${{jobs.check.outputs.should_skip}}" + +jobs: + check: + name: "skip-duplicate-check" + runs-on: "ubuntu-24.04" + outputs: + should_skip: "${{steps.skip_check.outputs.should_skip}}" + steps: + - id: "skip_check" + uses: "fkirc/skip-duplicate-actions@v5" + with: + # Skip duplicate runs for the same content (e.g., when both push and pull_request trigger) + concurrent_skipping: "same_content" + skip_after_successful_duplicate: "true" + # Always run for scheduled builds and manual triggers. + # NOTE: This is a JSON array string (required by the action), with escaped quotes for + # yamllint compliance. + do_not_skip: "[\"schedule\", \"workflow_dispatch\"]"