1- # Adds a label to PRs that touch documentation paths until a maintainer approves.
1+ # Docs review hold — workflow 1/3
2+ #
3+ # Purpose: avoid pulling the docs team into a PR review before the code is
4+ # directionally approved by a maintainer. This workflow adds
5+ # "docs review on hold" to any PR touching documentation paths, and the label is
6+ # cleared automatically once a MEMBER or OWNER approves (see check_docs_review.yml).
7+ #
8+ # Design is intentionally best-effort. Edge cases such as an approval being later
9+ # dismissed without a new commit are accepted — the label corrects itself on the
10+ # next push. add and check/remove use separate concurrency groups (pr-labels-add-*
11+ # vs pr-labels-check-*) so a new push cannot cancel a pending approval-check run.
12+ # Each workflow independently checks state before acting, so concurrent runs
13+ # across groups are safe.
14+ #
215# Currently dedicated to the docs review flow. If a second use case appears, promote
316# this into a reusable workflow (`workflow_call`) with the label as an input.
417name : Add Docs Review Label
518
6- concurrency :
7- group : pr-labels-${{ github.event.pull_request.number }}
8- cancel-in-progress : false
9-
1019permissions :
1120 pull-requests : write
1221
2130 - " website/content/**"
2231 - " website/cue/reference/**"
2332
33+ concurrency :
34+ group : pr-labels-add-${{ github.event.pull_request.number }}
35+ cancel-in-progress : false
36+
2437env :
2538 LABEL_NAME : " docs review on hold"
2639
@@ -29,34 +42,21 @@ jobs:
2942 runs-on : ubuntu-24.04
3043 timeout-minutes : 5
3144 steps :
32- - name : Check member review state
45+ - name : Check member approval
3346 id : check
3447 uses : actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
3548 with :
3649 script : |
37- const { data: reviews } = await github.rest.pulls.listReviews( {
50+ const reviews = await github.paginate(github. rest.pulls.listReviews, {
3851 owner: context.repo.owner,
3952 repo: context.repo.repo,
4053 pull_number: context.payload.pull_request.number,
4154 per_page: 100,
4255 });
43-
4456 const allowed = ['MEMBER', 'OWNER'];
45- const latestByUser = new Map();
46- for (const r of reviews) {
47- if (!allowed.includes(r.author_association)) continue;
48- if (r.state === 'COMMENTED') continue;
49- latestByUser.set(r.user.id, r.state);
50- }
51-
52- const states = [...latestByUser.values()];
53- const hasApproved = states.includes('APPROVED');
54- const hasChangesRequested = states.includes('CHANGES_REQUESTED');
55- const skip = hasApproved && !hasChangesRequested;
56-
57- core.info(`Latest member review states: ${states.join(', ') || '(none)'}`);
58- core.info(`skip=${skip}`);
59- core.setOutput('skip', skip);
57+ const approved = reviews.some(r => allowed.includes(r.author_association) && r.state === 'APPROVED');
58+ core.info(`Member approval found: ${approved}`);
59+ core.setOutput('skip', String(approved));
6060 - if : steps.check.outputs.skip != 'true'
6161 uses : actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf # v1.1.3
6262 with :
0 commit comments