Skip to content

Commit

Permalink
Renintroduce pull_request in GitHub workflow with if case
Browse files Browse the repository at this point in the history
The disadvantage of removing the `pull_request` as trigger event for an
GitHub workflow is that it does not trigger for pushes from a foreign
repo. To run the workflow also in this case without running the workflow
twice for PRs based on the original repo we introduce an if case that
runs the `pull_request` event only when it from a foreign repo.
  • Loading branch information
agoscinski committed Nov 28, 2024
1 parent 87cf264 commit cacb261
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: ci

on: [push]
on: [push, pull_request]

jobs:

pre-commit:
# runs only on pull request when from foreign repo, prevents duplicate runs
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

Expand All @@ -19,6 +21,8 @@ jobs:
- uses: pre-commit/[email protected]

tests:
# runs only on pull request when from foreign repo, prevents duplicate runs
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
timeout-minutes: 30
Expand Down

0 comments on commit cacb261

Please sign in to comment.