From 50a3f208ea8f1046b6d004627398ed8627e75b43 Mon Sep 17 00:00:00 2001 From: Josh de Leeuw Date: Fri, 17 Jan 2025 10:08:28 -0500 Subject: [PATCH 1/6] Avoid running action more than once when push to a PR --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c0b1bfdd..cb156b7e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,7 +5,8 @@ on: [push, pull_request] jobs: test: name: Build, lint, and test on Node.js ${{ matrix.node }} - + # Prevent the action running twice when the event is both a push and pull request + if: github.event_name != 'push' || github.event_name == 'push && !github.event.pull_request runs-on: ubuntu-latest strategy: matrix: From 846602b45f68d91b2347fe1d796732900afd7bd7 Mon Sep 17 00:00:00 2001 From: Josh de Leeuw Date: Fri, 17 Jan 2025 10:09:48 -0500 Subject: [PATCH 2/6] Fix typo --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cb156b7e..cc137c92 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,7 +6,7 @@ jobs: test: name: Build, lint, and test on Node.js ${{ matrix.node }} # Prevent the action running twice when the event is both a push and pull request - if: github.event_name != 'push' || github.event_name == 'push && !github.event.pull_request + if: github.event_name != 'push' || github.event_name == 'push' && !github.event.pull_request runs-on: ubuntu-latest strategy: matrix: From df83261d745b5d114279fa064f3e950e15c6d445 Mon Sep 17 00:00:00 2001 From: Josh de Leeuw Date: Fri, 17 Jan 2025 11:02:29 -0500 Subject: [PATCH 3/6] Use `concurrency` instead of `if` --- .github/workflows/build.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cc137c92..a75f98fb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,11 +2,13 @@ name: build on: [push, pull_request] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: test: name: Build, lint, and test on Node.js ${{ matrix.node }} - # Prevent the action running twice when the event is both a push and pull request - if: github.event_name != 'push' || github.event_name == 'push' && !github.event.pull_request runs-on: ubuntu-latest strategy: matrix: From 6079c29522aa803a933fea17a689464272b22999 Mon Sep 17 00:00:00 2001 From: Josh de Leeuw Date: Fri, 17 Jan 2025 11:11:55 -0500 Subject: [PATCH 4/6] Use branch instead of ref --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a75f98fb..4793ea8a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: build on: [push, pull_request] concurrency: - group: ${{ github.workflow }}-${{ github.ref }} + group: ci-${{ github.workflow }}-${{ github.head_ref || github.ref_name }} cancel-in-progress: true jobs: From 14b2586db193d024d42cce9a8dda1c682846cf7e Mon Sep 17 00:00:00 2001 From: Josh de Leeuw Date: Fri, 17 Jan 2025 11:29:47 -0500 Subject: [PATCH 5/6] Try a different conditional --- .github/workflows/build.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4793ea8a..e875fba7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,12 +2,9 @@ name: build on: [push, pull_request] -concurrency: - group: ci-${{ github.workflow }}-${{ github.head_ref || github.ref_name }} - cancel-in-progress: true - jobs: test: + if: github.event_name == 'push' && !contains(github.ref, '/merge') || github.event_name == 'pull_request' name: Build, lint, and test on Node.js ${{ matrix.node }} runs-on: ubuntu-latest strategy: From 236657da5687414a4f2ebf706ce7009e3094d7aa Mon Sep 17 00:00:00 2001 From: Josh de Leeuw Date: Fri, 17 Jan 2025 11:37:20 -0500 Subject: [PATCH 6/6] Change approach again, use `types` to limit which pull requests trigger the event --- .github/workflows/build.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e875fba7..0c79eed9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,10 +1,12 @@ name: build -on: [push, pull_request] +on: + push: + pull_request: + types: [opened, reopened, ready_for_review, review_requested] jobs: test: - if: github.event_name == 'push' && !contains(github.ref, '/merge') || github.event_name == 'pull_request' name: Build, lint, and test on Node.js ${{ matrix.node }} runs-on: ubuntu-latest strategy: