From 540ac8939c5768089cbafd05139eff8d2b2dd2f6 Mon Sep 17 00:00:00 2001 From: Constrat <56174894+Constrat@users.noreply.github.com> Date: Fri, 13 Dec 2024 14:22:30 +0100 Subject: [PATCH] ci: prevent duplicate runs (#11362) From https://github.com/zopefoundation/meta/issues/145#issuecomment-1247814559 --- .github/workflows/ci.yml | 31 ++++++++++++++++++++++++++++- .github/workflows/smoke-testing.yml | 4 ++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5007d77ec3..7120637ebc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,6 +34,11 @@ concurrency: jobs: meta: + # Prevent duplicate runs on organization branches with PRs + if: github.event_name != 'pull_request' || + github.event.pull_request.head.repo.full_name != + github.event.pull_request.base.repo.full_name + runs-on: ubuntu-latest outputs: tag: ${{ steps.set_tag.outputs.tag }} @@ -93,6 +98,11 @@ jobs: path: CHANGELOG.md windows: + # Prevent duplicate runs on organization branches with PRs + if: github.event_name != 'pull_request' || + github.event.pull_request.head.repo.full_name != + github.event.pull_request.base.repo.full_name + needs: meta strategy: matrix: @@ -183,6 +193,11 @@ jobs: path: artifacts ubuntu: + # Prevent duplicate runs on organization branches with PRs + if: github.event_name != 'pull_request' || + github.event.pull_request.head.repo.full_name != + github.event.pull_request.base.repo.full_name + needs: meta runs-on: ubuntu-latest strategy: @@ -295,6 +310,11 @@ jobs: release/*.tar.gz macOS-Core: + # Prevent duplicate runs on organization branches with PRs + if: github.event_name != 'pull_request' || + github.event.pull_request.head.repo.full_name != + github.event.pull_request.base.repo.full_name + needs: meta runs-on: macos-14 strategy: @@ -333,6 +353,11 @@ jobs: path: "install/*.dylib" macOS-GUI: + # Prevent duplicate runs on organization branches with PRs + if: github.event_name != 'pull_request' || + github.event.pull_request.head.repo.full_name != + github.event.pull_request.base.repo.full_name + needs: [meta, macOS-Core] runs-on: macos-14 steps: @@ -466,7 +491,11 @@ jobs: path: ${{ startsWith(github.ref, 'refs/tags/v') && 'release/MAA*' || 'src/MaaMacGui/MAA.xcarchive/**' }} release: - if: startsWith(github.ref, 'refs/tags/v') + # Prevent duplicate runs on organization branches with PRs + if: (github.event_name != 'pull_request' || + github.event.pull_request.head.repo.full_name != + github.event.pull_request.base.repo.full_name) && startsWith(github.ref, 'refs/tags/v') + needs: [meta, windows, ubuntu, macOS-GUI] runs-on: ubuntu-latest steps: diff --git a/.github/workflows/smoke-testing.yml b/.github/workflows/smoke-testing.yml index 6f16c4d22e..cef12d8ea4 100644 --- a/.github/workflows/smoke-testing.yml +++ b/.github/workflows/smoke-testing.yml @@ -31,6 +31,10 @@ concurrency: jobs: smoke-testing: + # Prevent duplicate runs on organization branches with PRs + if: github.event_name != 'pull_request' || + github.event.pull_request.head.repo.full_name != + github.event.pull_request.base.repo.full_name runs-on: windows-latest steps: - name: Checkout code