Skip to content

Commit 9b01e09

Browse files
workflows: avoid running jobs when editing title etc.
We intend to use the edited event to react to base branch changes - but before this change, we also ran those jobs on simple edits like title or description. While this works for some of the quicker jobs, it will not be sustainable for all evaluation-related jobs. But evaluation needs to be re-triggered on a base branch change as well, thus this change.
1 parent d4b3be9 commit 9b01e09

File tree

6 files changed

+50
-10
lines changed

6 files changed

+50
-10
lines changed

.github/workflows/check-format.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: Check that files are formatted
22

33
on:
44
pull_request_target:
5-
types: [opened, synchronize, reopened, edited]
65

76
permissions: {}
87

.github/workflows/codeowners-v2.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ name: Codeowners v2
2424

2525
on:
2626
pull_request_target:
27-
types: [opened, ready_for_review, synchronize, reopened, edited]
27+
types: [opened, ready_for_review, synchronize, reopened]
2828

2929
permissions: {}
3030

.github/workflows/edited.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Some workflows depend on the base branch of the PR, but changing the base branch is not included in the default trigger events, which would be `opened`, `synchronize` or `reopened`.
2+
# Instead it causes an `edited` event.
3+
# Since `edited` is also triggered when PR title/body is changed, we use this wrapper workflow, to run the other workflows conditionally only.
4+
# There are already feature requests for adding a `base_changed` event:
5+
# - https://github.com/orgs/community/discussions/35058
6+
# - https://github.com/orgs/community/discussions/64119
7+
#
8+
# Instead of adding this to each workflow's pull_request_target event, we trigger this in a separate workflow.
9+
# This has the advantage, that we can actually skip running those jobs for simple edits like changing the title or description.
10+
# The actual trigger happens by closing and re-opening the pull request, which triggers the default pull_request_target events.
11+
# This is much simpler and reliable than other approaches.
12+
13+
name: "Edited base branch"
14+
15+
on:
16+
pull_request_target:
17+
types: [edited]
18+
19+
permissions: {}
20+
21+
jobs:
22+
base:
23+
name: Trigger jobs
24+
runs-on: ubuntu-24.04
25+
if: github.event.changes.base.ref.from && github.event.changes.base.ref.from != github.event.pull_request.base.ref
26+
steps:
27+
# Use a GitHub App to create the PR so that CI gets triggered
28+
# The App is scoped to Repository > Contents and Pull Requests: write for Nixpkgs
29+
# We only need Pull Requests: write here, but the app is also used for backports.
30+
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
31+
id: app-token
32+
with:
33+
app-id: ${{ vars.NIXPKGS_CI_APP_ID }}
34+
private-key: ${{ secrets.NIXPKGS_CI_APP_PRIVATE_KEY }}
35+
permission-pull-requests: write
36+
37+
- env:
38+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
39+
REPOSITORY: ${{ github.repository }}
40+
NUMBER: ${{ github.event.number }}
41+
run: |
42+
gh api \
43+
--method PATCH \
44+
/repos/"$REPOSITORY"/pulls/"$NUMBER" \
45+
-f "state=closed"
46+
gh api \
47+
--method PATCH \
48+
/repos/"$REPOSITORY"/pulls/"$NUMBER" \
49+
-f "state=open"

.github/workflows/labels.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ name: "Label PR"
77

88
on:
99
pull_request_target:
10-
types: [edited, opened, synchronize, reopened]
1110

1211
permissions:
1312
contents: read

.github/workflows/nixpkgs-vet.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ name: Vet nixpkgs
77

88
on:
99
pull_request_target:
10-
# This workflow depends on the base branch of the PR, but changing the base branch is not included in the default trigger events, which would be `opened`, `synchronize` or `reopened`.
11-
# Instead it causes an `edited` event, so we need to add it explicitly here.
12-
# While `edited` is also triggered when the PR title/body is changed, this PR action is fairly quick, and PRs don't get edited **that** often, so it shouldn't be a problem.
13-
# There is a feature request for adding a `base_changed` event: https://github.com/orgs/community/discussions/35058
14-
types: [opened, synchronize, reopened, edited]
1510

1611
permissions: {}
1712

.github/workflows/no-channel.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: "No channel PR"
22

33
on:
44
pull_request_target:
5-
# Re-run should be triggered when the base branch is updated, instead of silently failing
6-
types: [opened, synchronize, reopened, edited]
75

86
permissions: {}
97

0 commit comments

Comments
 (0)