Skip to content

Commit 7b0400a

Browse files
workflows/eval: run when base branch changed (#372475)
2 parents 66cc5bf + 9b01e09 commit 7b0400a

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
@@ -5,7 +5,6 @@ on:
55
paths:
66
- .github/workflows/check-format.yml
77
pull_request_target:
8-
types: [opened, synchronize, reopened, edited]
98

109
permissions: {}
1110

.github/workflows/codeowners-v2.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ on:
2727
paths:
2828
- .github/workflows/codeowners-v2.yml
2929
pull_request_target:
30-
types: [opened, ready_for_review, synchronize, reopened, edited]
30+
types: [opened, ready_for_review, synchronize, reopened]
3131

3232
permissions: {}
3333

.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
@@ -10,11 +10,6 @@ on:
1010
paths:
1111
- .github/workflows/nixpkgs-vet.yml
1212
pull_request_target:
13-
# 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`.
14-
# Instead it causes an `edited` event, so we need to add it explicitly here.
15-
# 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.
16-
# There is a feature request for adding a `base_changed` event: https://github.com/orgs/community/discussions/35058
17-
types: [opened, synchronize, reopened, edited]
1813

1914
permissions: {}
2015

.github/workflows/no-channel.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ on:
55
paths:
66
- .github/workflows/no-channel.yml
77
pull_request_target:
8-
# Re-run should be triggered when the base branch is updated, instead of silently failing
9-
types: [opened, synchronize, reopened, edited]
108

119
permissions: {}
1210

0 commit comments

Comments
 (0)