33# The app was suspended and its check silently stopped appearing after #1981
44# (2026-08-12). Nothing went red, because it was never a required check — so
55# for two months "the DCO check is a hard merge gate" was true only by habit.
6- # This job is the repo-owned replacement: `scripts/dco-check.mjs` fails the PR
7- # unless every commit in it carries a `Signed-off-by:` matching its author or
8- # committer (merge and bot-authored commits exempt — the app's rule).
6+ # This workflow is the repo-owned replacement: `scripts/dco-check.mjs` fails
7+ # unless every commit in a range carries a `Signed-off-by:` matching its
8+ # author or committer (merge and bot-authored commits exempt — the app's rule).
99#
10- # ⚠️ A job only GATES when its check is required. Making `DCO` a required
11- # status check is a ruleset change in repo settings (one covering `v2/main`
12- # does not exist yet), not something a workflow file can do — without it, this
13- # job going missing would pass as silently as the app did.
10+ # Two jobs, one script:
1411#
15- # Its own workflow because it needs the PR's base, which `main.yml` (push
16- # only) never sees.
12+ # - `DCO` — on every v2 PR, over the PR's commits. This is the
13+ # one to make a REQUIRED status check (a ruleset change in repo settings,
14+ # not something this file can do — without it, the job going missing
15+ # passes as silently as the app did).
16+ # - `DCO (v2/main push)` — a backstop over every push that lands on
17+ # `v2/main`, for whatever reached the branch without a passing PR check
18+ # while this file and the script stayed intact: an admin merge, a direct
19+ # push, a merge made while the PR check was red or missing. NOT a PR that
20+ # edited the check itself (below).
21+ # It reports when the commit lands, not one milestone later — it cannot
22+ # un-merge anything, but an unsigned commit found the same day is still
23+ # cheap to deal with.
1724#
18- # ⚠️ `pull_request_target`, deliberately — a check that gates a PR must not run
19- # code the PR can change. Under `pull_request` both this file and the script
20- # come from the PR's merge ref, so a PR could rewrite either to pass itself.
21- # `pull_request_target` takes the workflow from the repo's DEFAULT branch
22- # (`main`), and the job checks out the PR's base (`v2/main`) for the script —
23- # both already-merged code. The PR's commits are only FETCHED: `git log` reads
24- # their metadata and nothing from the PR is ever executed, which is the
25- # condition that makes `pull_request_target` safe. Keep it that way: never
26- # check out, install, build or run the PR head in this job.
25+ # ⚠️ `pull_request`, not `pull_request_target` (#2616). #2603 shipped on
26+ # `pull_request_target` so a PR could not rewrite its own check to pass — but
27+ # GitHub reads `pull_request_target` workflows from the DEFAULT branch
28+ # (`main`), so the check reported on no v2 PR at all until a milestone merge
29+ # carried this file there, and unsigned commits would have surfaced only when
30+ # the milestone PR into `main` was opened. Under `pull_request` the workflow
31+ # runs from the PR's own ref and works the moment it is on `v2/main`, and an
32+ # edit to this file takes effect on the PR that makes it.
2733#
28- # ⚠️ Rollout follows from the workflow living on `main`: this file does
29- # nothing until a milestone merge carries it from `v2/main` to `main`, and a
30- # later edit to it takes effect only on the next milestone merge. An edit to
31- # `scripts/dco-check.mjs` takes effect as soon as it merges to `v2/main`. Make
32- # `DCO` a required check only once this file is on `main` — required before
33- # then, every v2 PR would wait on a check that never reports.
34+ # The trade-off, accepted deliberately: a PR can now edit this file to pass
35+ # itself. That is tolerable here because PRs are opened by maintainers only
36+ # (AGENTS.md, Contributing) and the check exists to catch a FORGOTTEN signoff,
37+ # not a forged one — the trailer is self-asserted text either way (see the
38+ # header of `scripts/dco-check.mjs`). ⚠️ The push job does NOT cover that
39+ # case: a `push` run also reads this file, and runs the script, from the
40+ # pushed revision — so a PR that edits the check edits the backstop with it.
41+ # Nothing in a workflow the repo's own branches carry can close that; only a
42+ # check read from elsewhere could, which is what `pull_request_target` was and
43+ # what this change gives up. The control for it is review: an edit to this
44+ # file or to `scripts/dco-check.mjs` is in the PR's diff. The PR job keeps the
45+ # trigger safe anyway: it checks out the PR's BASE for the script and only
46+ # FETCHES the PR's commits, reading their metadata with `git log` — nothing
47+ # from the PR is checked out, installed, built or run.
3448#
35- # Scoped to `v2/main`. Once on `main` an unscoped trigger would also fire for
36- # `v1/main` PRs (whose checkout has no script) and for milestone PRs into
37- # `main` (whose range holds GitHub's squash-merge commits, signed under a
38- # different name). `edited` re-runs it when a PR is retargeted, since the
39- # checked range changes with the base even when the head does not.
49+ # The PR job runs on every `v2/**` base — `v2/main` and, since branch names
50+ # carry their version segment, every v2 feature branch — so a stacked PR is
51+ # checked on its own range rather than only once its parent merges (the
52+ # servers repo's #5055 checks stacks too). A positive filter rather than a
53+ # list of exclusions, so the scope is the v2 line by construction: `main`
54+ # (milestone PRs carry GitHub's squash-merge commits and reach back before the
55+ # check existed) and the whole v1 line, `v1/main` and its stacks alike (no copy
56+ # of the script), are out of it without being named. A stacked PR's base must
57+ # be a branch cut after #2603, since the script is read from it. `edited` re-runs the PR job when a PR is retargeted,
58+ # since the checked range changes with the base even when the head does not.
59+ #
60+ # Before either job, `npm run local:gate` runs the same script over
61+ # `origin/v2/main..HEAD`, minus anything already on `origin/main` so it holds
62+ # on a milestone-merge branch too (`local:dco`), so an unsigned commit is normally
63+ # caught before it is pushed at all.
4064#
4165# Only `contents: read`, no credential persisted, no secret — so it stays on
4266# moving action tags (#2235; see verify:action-pins, #2484).
4367name : DCO
4468
4569on :
46- pull_request_target :
70+ pull_request :
4771 types : [opened, synchronize, reopened, edited]
72+ branches : ['v2/**']
73+ push :
4874 branches : [v2/main]
4975
5076permissions :
@@ -53,14 +79,21 @@ permissions:
5379jobs :
5480 dco :
5581 name : DCO
82+ if : github.event_name == 'pull_request'
5683 runs-on : ubuntu-latest
84+ # A newer push to the same PR supersedes the range being checked. Job-level
85+ # and PR-keyed on purpose: the push job below must NOT share it, since a
86+ # cancelled push run is a range that is never checked.
87+ concurrency :
88+ group : dco-pr-${{ github.event.pull_request.number }}
89+ cancel-in-progress : true
5790 # A git fetch, a git log and a node script; expected to finish well inside
5891 # a minute. Not yet observed on a runner — revisit with the measured range
5992 # per the rule in main.yml (#2333) once it has a history.
6093 timeout-minutes : 5
6194
6295 steps :
63- - name : Checkout the base branch (trusted) with full history
96+ - name : Checkout the base branch with full history
6497 uses : actions/checkout@v7
6598 with :
6699 ref : ${{ github.base_ref }}
@@ -87,3 +120,39 @@ jobs:
87120 BASE_REF : ${{ github.base_ref }}
88121 HEAD_SHA : ${{ github.event.pull_request.head.sha }}
89122 run : node scripts/dco-check.mjs --base "origin/$BASE_REF" --head "$HEAD_SHA"
123+
124+ dco-push :
125+ name : DCO (v2/main push)
126+ if : github.event_name == 'push'
127+ runs-on : ubuntu-latest
128+ # Same work as the PR job; same unmeasured budget.
129+ timeout-minutes : 5
130+
131+ steps :
132+ - name : Checkout the pushed commit with full history
133+ uses : actions/checkout@v7
134+ with :
135+ fetch-depth : 0
136+ persist-credentials : false
137+
138+ - name : Setup Node.js
139+ uses : actions/setup-node@v7
140+ with :
141+ node-version : ' 22.x'
142+
143+ - name : Check every pushed commit is signed off
144+ # `before..after` is exactly what the push added: for a PR merge, the
145+ # merge commit (exempt) plus every commit it brought in. A zero
146+ # `before` means the branch was just created, which leaves no range to
147+ # check. A `before` missing from the history (a force-push that
148+ # rewrote it away) makes `git log` fail and the script exit 2 — loud
149+ # on purpose, since `v2/main` is never meant to be rewritten.
150+ env :
151+ BEFORE : ${{ github.event.before }}
152+ AFTER : ${{ github.event.after }}
153+ run : |
154+ if [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then
155+ echo "Branch creation push: no prior commit, nothing to check."
156+ exit 0
157+ fi
158+ node scripts/dco-check.mjs --base "$BEFORE" --head "$AFTER"
0 commit comments