Repository navigation
63 lines (58 loc) · 2.39 KB
/
Copy pathadd_docs_review_label.yml
File metadata and controls
63 lines (58 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Docs review hold — workflow 1/3
#
# Purpose: avoid pulling the docs team into a PR review before the code is
# directionally approved by a maintainer. This workflow adds
# "docs review on hold" to any PR touching documentation paths, and the label is
# cleared automatically once a MEMBER or OWNER approves (see check_docs_review.yml).
#
# Design is intentionally best-effort. Edge cases such as an approval being later
# dismissed without a new commit are accepted — the label corrects itself on the
# next push. add and check/remove use separate concurrency groups (pr-labels-add-*
# vs pr-labels-check-*) so a new push cannot cancel a pending approval-check run.
# Each workflow independently checks state before acting, so concurrent runs
# across groups are safe.
#
# Currently dedicated to the docs review flow. If a second use case appears, promote
# this into a reusable workflow (`workflow_call`) with the label as an input.
name: Add Docs Review Label
permissions:
pull-requests: write
on:
pull_request_target:
types: [opened, reopened, synchronize]
# Keep these paths in sync with the documentation team entries in .github/CODEOWNERS
paths:
- "*.md"
- "docs/**"
- "deprecation.d/**"
- "website/content/**"
- "website/cue/reference/**"
concurrency:
group: pr-labels-add-${{ github.event.pull_request.number }}
cancel-in-progress: false
env:
LABEL_NAME: "docs review on hold"
jobs:
add_label:
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- name: Check member approval
id: check
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const reviews = await github.paginate(github.rest.pulls.listReviews, {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
per_page: 100,
});
const allowed = ['MEMBER', 'OWNER'];
const approved = reviews.some(r => allowed.includes(r.author_association) && r.state === 'APPROVED');
core.info(`Member approval found: ${approved}`);
core.setOutput('skip', String(approved));
- if: steps.check.outputs.skip != 'true'
uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf # v1.1.3
with:
labels: ${{ env.LABEL_NAME }}