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 timeout-minutes: 2 35 steps: 36 # Use a GitHub App to create the PR so that CI gets triggered 37 # The App is scoped to Repository > Contents and Pull Requests: write for Nixpkgs 38 # We only need Pull Requests: write here, but the app is also used for backports. 39 - uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4 40 id: app-token 41 with: 42 app-id: ${{ vars.NIXPKGS_CI_APP_ID }} 43 private-key: ${{ secrets.NIXPKGS_CI_APP_PRIVATE_KEY }} 44 permission-pull-requests: write 45 46 - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 47 with: 48 github-token: ${{ steps.app-token.outputs.token }} 49 script: | 50 function changeState(state) { 51 return github.rest.pulls.update({ 52 owner: context.repo.owner, 53 repo: context.repo.repo, 54 pull_number: context.payload.pull_request.number, 55 state 56 }) 57 } 58 await changeState('closed') 59 await changeState('open')