Skip to content

Commit 7679535

Browse files
authored
ci: docs pr checker (#845)
## fixes KILTprotocol/ticket#2890 Make docs PR mandatory ## Checklist: - [ ] I have verified that the code works - [ ] No panics! (checked arithmetic ops, no indexing `array[3]` use `get(3)`, ...) - [ ] I have verified that the code is easy to understand - [ ] If not, I have left a well-balanced amount of inline comments - [ ] I have [left the code in a better state](https://deviq.com/principles/boy-scout-rule) - [ ] I have documented the changes (where applicable) * Either PR or Ticket to update [the Docs](https://github.com/KILTprotocol/docs) * Link the PR/Ticket here
1 parent 3ff5264 commit 7679535

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

.github/workflows/check-docs-pr.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Docs PR Check
2+
3+
on:
4+
pull_request:
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref_name }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
check-docs-pr:
12+
runs-on: ubuntu-latest
13+
env:
14+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
15+
16+
steps:
17+
- name: Checkout Code
18+
uses: actions/checkout@v4
19+
20+
- name: Check for Skip Label
21+
run: |
22+
if gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels | .[].name' | grep -q 'ci-skip-docs-pr'; then
23+
echo "SKIP_DOCS_PR_CHECK=true" >> $GITHUB_ENV
24+
else
25+
echo "SKIP_DOCS_PR_CHECK=false" >> $GITHUB_ENV
26+
fi
27+
28+
- name: Ensure Linked Docs PR
29+
if: env.SKIP_DOCS_PR_CHECK == 'false'
30+
env:
31+
DOCS_REPO: KILTprotocol/docs
32+
PR_NO: ${{ github.event.pull_request.number }}
33+
run: |
34+
DOCS_PRS=$(gh pr list --repo $DOCS_REPO --json number,body,title --jq '.[]')
35+
36+
MATCHING_PR=$(echo "$DOCS_PRS" | jq -r "select(.body | contains(\"#${PR_NO}\") or .title | contains(\"#${PR_NO}\"))")
37+
38+
if [ -z "$MATCHING_PR" ]; then
39+
echo "Please link a docs PR for code PR #${PR_NO} or apply the 'ci-skip-docs-pr' label."
40+
exit 1
41+
else
42+
echo "Matching docs PR found for code PR #${PR_NOPR_NO}."
43+
fi

0 commit comments

Comments
 (0)