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
13name: "Edited base branch"
14
15on:
16 pull_request_target:
17 types: [edited]
18
19concurrency:
20 group: edited-${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.run_id }}
21 cancel-in-progress: true
22
23permissions: {}
24
25defaults:
26 run:
27 shell: bash
28
29jobs:
30 base:
31 name: Trigger jobs
32 runs-on: ubuntu-24.04
33 if: github.event.changes.base.ref.from && github.event.changes.base.ref.from != github.event.pull_request.base.ref
34 steps:
35 # Use a GitHub App to create the PR so that CI gets triggered
36 # The App is scoped to Repository > Contents and Pull Requests: write for Nixpkgs
37 # We only need Pull Requests: write here, but the app is also used for backports.
38 - uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
39 id: app-token
40 with:
41 app-id: ${{ vars.NIXPKGS_CI_APP_ID }}
42 private-key: ${{ secrets.NIXPKGS_CI_APP_PRIVATE_KEY }}
43 permission-pull-requests: write
44
45 - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
46 with:
47 github-token: ${{ steps.app-token.outputs.token }}
48 script: |
49 function changeState(state) {
50 return github.rest.pulls.update({
51 owner: context.repo.owner,
52 repo: context.repo.repo,
53 pull_number: context.payload.pull_request.number,
54 state
55 })
56 }
57 await changeState('closed')
58 await changeState('open')