Skip to content

Commit a4df906

Browse files
authored
Trigger CI on push or pull_request but not both (#5142)
1 parent 176c6eb commit a4df906

File tree

3 files changed

+58
-6
lines changed

3 files changed

+58
-6
lines changed

.github/workflows/ci-additional.yaml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,26 @@ on:
99
workflow_dispatch: # allows you to trigger manually
1010

1111
jobs:
12-
detect-ci-trigger:
13-
name: detect ci trigger
12+
skip-duplicate-jobs:
1413
runs-on: ubuntu-latest
1514
if: |
1615
github.repository == 'pydata/xarray'
1716
&& (github.event_name == 'push' || github.event_name == 'pull_request')
17+
outputs:
18+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
19+
steps:
20+
- id: skip_check
21+
uses: fkirc/[email protected]
22+
with:
23+
# For workflows which are triggered concurrently with the same
24+
# contents, attempt to execute them exactly once.
25+
concurrent_skipping: 'same_content_newer'
26+
paths_ignore: '["**/doc/**"]'
27+
detect-ci-trigger:
28+
name: detect ci trigger
29+
runs-on: ubuntu-latest
30+
needs: skip-duplicate-jobs
31+
if: ${{ needs.skip-duplicate-jobs.outputs.should_skip != 'true' }}
1832
outputs:
1933
triggered: ${{ steps.detect-trigger.outputs.trigger-found }}
2034
steps:
@@ -115,7 +129,8 @@ jobs:
115129
doctest:
116130
name: Doctests
117131
runs-on: "ubuntu-latest"
118-
if: github.repository == 'pydata/xarray'
132+
needs: skip-duplicate-jobs
133+
if: ${{ needs.skip-duplicate-jobs.outputs.should_skip != 'true' }}
119134
defaults:
120135
run:
121136
shell: bash -l {0}

.github/workflows/ci.yaml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,27 @@ on:
99
workflow_dispatch: # allows you to trigger manually
1010

1111
jobs:
12-
detect-ci-trigger:
13-
name: detect ci trigger
12+
skip-duplicate-jobs:
1413
runs-on: ubuntu-latest
1514
if: |
1615
github.repository == 'pydata/xarray'
1716
&& (github.event_name == 'push' || github.event_name == 'pull_request')
17+
outputs:
18+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
19+
steps:
20+
- id: skip_check
21+
uses: fkirc/[email protected]
22+
with:
23+
# For workflows which are triggered concurrently with the same
24+
# contents, attempt to execute them exactly once.
25+
concurrent_skipping: 'same_content_newer'
26+
paths_ignore: '["**/doc/**"]'
27+
28+
detect-ci-trigger:
29+
name: detect ci trigger
30+
needs: skip-duplicate-jobs
31+
if: ${{ needs.skip-duplicate-jobs.outputs.should_skip != 'true' }}
32+
runs-on: ubuntu-latest
1833
outputs:
1934
triggered: ${{ steps.detect-trigger.outputs.trigger-found }}
2035
steps:
@@ -110,6 +125,8 @@ jobs:
110125

111126
event_file:
112127
name: "Event File"
128+
needs: skip-duplicate-jobs
129+
if: ${{ needs.skip-duplicate-jobs.outputs.should_skip != 'true' }}
113130
runs-on: ubuntu-latest
114131
steps:
115132
- name: Upload

.github/workflows/publish-test-results.yaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,30 @@ on:
99
- completed
1010

1111
jobs:
12+
13+
skip-duplicate-jobs:
14+
runs-on: ubuntu-latest
15+
if: |
16+
github.repository == 'pydata/xarray'
17+
&& (github.event_name == 'push' || github.event_name == 'pull_request')
18+
outputs:
19+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
20+
steps:
21+
- id: skip_check
22+
uses: fkirc/[email protected]
23+
with:
24+
# For workflows which are triggered concurrently with the same
25+
# contents, attempt to execute them exactly once.
26+
concurrent_skipping: 'same_content_newer'
27+
paths_ignore: '["**/doc/**"]'
28+
1229
publish-test-results:
1330
name: Publish test results
1431
runs-on: ubuntu-latest
15-
if: github.event.workflow_run.conclusion != 'skipped'
32+
needs: skip-duplicate-jobs
33+
if: |
34+
needs.skip-duplicate-jobs.outputs.should_skip != 'true'
35+
&& github.event.workflow_run.conclusion != 'skipped'
1636
1737
steps:
1838
- name: Download and extract artifacts

0 commit comments

Comments
 (0)