Files
twenty/.github/workflows/pr-review-dispatch.yaml
T
Charles Bochet d4c3759c70 ci(pr-review): stop a skipped label dispatch from cancelling the open dispatch (#23856)
## Problem

The standard review silently does not run on PRs that get labelled by a
bot right after opening. https://github.com/twentyhq/twenty/pull/23854
is an example: no `PR Review #23854` run exists in `ci-privileged` at
all.

| time | what |
|---|---|
| 10:08:35 | PR opened |
| 10:08:39 | `twenty-eng-sync[bot]` adds the `-PR: draft` label |
| 10:08:40 | dispatch run for `opened` starts, cancelled during "Set up
job" |
| 10:08:43 | dispatch run for `labeled` is skipped by the job `if` |

Concurrency is evaluated before the job-level `if`, so the `labeled` run
preempts and cancels the in-flight `opened` run and is then skipped
itself (`-PR: draft` does not start with `pr-review-`). The sync bot
labels within ~4 seconds of open, which is faster than the app-token
mint step, so the `opened` dispatch loses this race essentially every
time that label is applied.

`opened` is the only event that resolves to the `standard` check, so
with no later push the PR gets no review at all. Same class of gap as
the one #23708 closed, moved down a layer: the trigger exists now but
gets cancelled.

## Fix

Scope the concurrency group by event action, and only cancel in-progress
runs for `synchronize`. Rapid consecutive pushes still de-duplicate;
`opened`, `ready_for_review` and `labeled` no longer cancel each other.

<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/twentyhq/twenty/pull/23856?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
2026-08-06 12:54:20 +02:00

41 lines
1.4 KiB
YAML

name: PR Review Dispatch
run-name: "PR Review Dispatch #${{ github.event.pull_request.number }}"
on:
pull_request_target:
types: [opened, ready_for_review, synchronize, labeled]
permissions: {}
concurrency:
group: pr-review-dispatch-${{ github.event.pull_request.number }}-${{ github.event.action }}
cancel-in-progress: ${{ github.event.action == 'synchronize' }}
jobs:
dispatch:
if: >
github.event.pull_request.draft == false &&
(github.event.action != 'labeled' || startsWith(github.event.label.name, 'pr-review-'))
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Mint ci-privileged dispatch token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ vars.TWENTY_WORKFLOW_DISPATCHER_CLIENT_ID }}
private-key: ${{ secrets.TWENTY_WORKFLOW_DISPATCHER_PRIVATE_KEY }}
owner: twentyhq
repositories: ci-privileged
permission-actions: write
- name: Forward to PR review
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
EVENT: ${{ github.event.action }}
run: |
gh workflow run pr-review.yaml --repo twentyhq/ci-privileged --ref main \
-f pr_number="$PR_NUMBER" \
-f event="$EVENT"