mirror of
https://github.com/CHN-beta/nixpkgs.git
synced 2026-01-12 02:40:31 +08:00
This didn't work as intended. When a workflow is run with `workflow_call`, it will have `github.workflow` set to the *parent* workflow. So the `caller` input that we passed, resulted in this concurrency key: ``` Eval-Eval-... ``` But that's bad, because the labels and reviewers workflows will cancel each other! What we actually want is this: - Label and Reviewers workflow should have different groups. - Reviewers called via Eval and called directly via undraft should have *different* groups. We can't use the default condition we use everywhere else, because `github.workflow` is the same for Label and Reviewers. Thus, we hardcode the workflow's name as well. This essentially means we have this as a key: ``` <name-of-running-workflow>-<name-of-triggering-workflow>-<name-of-event>-<name-of-head-branch> ``` This should do what we want. Since workflows can be made reusable workflows later on, we add those hardcoded names to *all* concurrency groups. This avoids copy&paste errors later on.
59 lines
2.5 KiB
YAML
59 lines
2.5 KiB
YAML
# 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`.
|
|
# Instead it causes an `edited` event.
|
|
# Since `edited` is also triggered when PR title/body is changed, we use this wrapper workflow, to run the other workflows conditionally only.
|
|
# There are already feature requests for adding a `base_changed` event:
|
|
# - https://github.com/orgs/community/discussions/35058
|
|
# - https://github.com/orgs/community/discussions/64119
|
|
#
|
|
# Instead of adding this to each workflow's pull_request_target event, we trigger this in a separate workflow.
|
|
# This has the advantage, that we can actually skip running those jobs for simple edits like changing the title or description.
|
|
# The actual trigger happens by closing and re-opening the pull request, which triggers the default pull_request_target events.
|
|
# This is much simpler and reliable than other approaches.
|
|
|
|
name: "Edited base branch"
|
|
|
|
on:
|
|
pull_request_target:
|
|
types: [edited]
|
|
|
|
concurrency:
|
|
group: edited-${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.run_id }}
|
|
cancel-in-progress: true
|
|
|
|
permissions: {}
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
|
|
jobs:
|
|
base:
|
|
name: Trigger jobs
|
|
runs-on: ubuntu-24.04
|
|
if: github.event.changes.base.ref.from && github.event.changes.base.ref.from != github.event.pull_request.base.ref
|
|
steps:
|
|
# Use a GitHub App to create the PR so that CI gets triggered
|
|
# The App is scoped to Repository > Contents and Pull Requests: write for Nixpkgs
|
|
# We only need Pull Requests: write here, but the app is also used for backports.
|
|
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
|
|
id: app-token
|
|
with:
|
|
app-id: ${{ vars.NIXPKGS_CI_APP_ID }}
|
|
private-key: ${{ secrets.NIXPKGS_CI_APP_PRIVATE_KEY }}
|
|
permission-pull-requests: write
|
|
|
|
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
|
with:
|
|
github-token: ${{ steps.app-token.outputs.token }}
|
|
script: |
|
|
function changeState(state) {
|
|
return github.rest.pulls.update({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
pull_number: context.payload.pull_request.number,
|
|
state
|
|
})
|
|
}
|
|
await changeState('closed')
|
|
await changeState('open')
|