Skip to content

Commit

Permalink
Trigger CI on push or pull_request but not both (#5142)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersy005 authored Jan 20, 2022
1 parent 176c6eb commit a4df906
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 6 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/ci-additional.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,26 @@ on:
workflow_dispatch: # allows you to trigger manually

jobs:
detect-ci-trigger:
name: detect ci trigger
skip-duplicate-jobs:
runs-on: ubuntu-latest
if: |
github.repository == 'pydata/xarray'
&& (github.event_name == 'push' || github.event_name == 'pull_request')
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/[email protected]
with:
# For workflows which are triggered concurrently with the same
# contents, attempt to execute them exactly once.
concurrent_skipping: 'same_content_newer'
paths_ignore: '["**/doc/**"]'
detect-ci-trigger:
name: detect ci trigger
runs-on: ubuntu-latest
needs: skip-duplicate-jobs
if: ${{ needs.skip-duplicate-jobs.outputs.should_skip != 'true' }}
outputs:
triggered: ${{ steps.detect-trigger.outputs.trigger-found }}
steps:
Expand Down Expand Up @@ -115,7 +129,8 @@ jobs:
doctest:
name: Doctests
runs-on: "ubuntu-latest"
if: github.repository == 'pydata/xarray'
needs: skip-duplicate-jobs
if: ${{ needs.skip-duplicate-jobs.outputs.should_skip != 'true' }}
defaults:
run:
shell: bash -l {0}
Expand Down
21 changes: 19 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,27 @@ on:
workflow_dispatch: # allows you to trigger manually

jobs:
detect-ci-trigger:
name: detect ci trigger
skip-duplicate-jobs:
runs-on: ubuntu-latest
if: |
github.repository == 'pydata/xarray'
&& (github.event_name == 'push' || github.event_name == 'pull_request')
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/[email protected]
with:
# For workflows which are triggered concurrently with the same
# contents, attempt to execute them exactly once.
concurrent_skipping: 'same_content_newer'
paths_ignore: '["**/doc/**"]'

detect-ci-trigger:
name: detect ci trigger
needs: skip-duplicate-jobs
if: ${{ needs.skip-duplicate-jobs.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
outputs:
triggered: ${{ steps.detect-trigger.outputs.trigger-found }}
steps:
Expand Down Expand Up @@ -110,6 +125,8 @@ jobs:

event_file:
name: "Event File"
needs: skip-duplicate-jobs
if: ${{ needs.skip-duplicate-jobs.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
steps:
- name: Upload
Expand Down
22 changes: 21 additions & 1 deletion .github/workflows/publish-test-results.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,30 @@ on:
- completed

jobs:

skip-duplicate-jobs:
runs-on: ubuntu-latest
if: |
github.repository == 'pydata/xarray'
&& (github.event_name == 'push' || github.event_name == 'pull_request')
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/[email protected]
with:
# For workflows which are triggered concurrently with the same
# contents, attempt to execute them exactly once.
concurrent_skipping: 'same_content_newer'
paths_ignore: '["**/doc/**"]'

publish-test-results:
name: Publish test results
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion != 'skipped'
needs: skip-duplicate-jobs
if: |
needs.skip-duplicate-jobs.outputs.should_skip != 'true'
&& github.event.workflow_run.conclusion != 'skipped'
steps:
- name: Download and extract artifacts
Expand Down

0 comments on commit a4df906

Please sign in to comment.