-
Notifications
You must be signed in to change notification settings - Fork 47
43 lines (35 loc) · 1.3 KB
/
check-docs-pr.yml
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
name: Docs PR Check
on:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
check-docs-pr:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Check for Skip Label
run: |
if gh pr view ${{ github.event.pull_request.number }} --json labels --jq '.labels | .[].name' | grep -q 'ci-skip-docs-pr'; then
echo "SKIP_DOCS_PR_CHECK=true" >> $GITHUB_ENV
else
echo "SKIP_DOCS_PR_CHECK=false" >> $GITHUB_ENV
fi
- name: Ensure Linked Docs PR
if: env.SKIP_DOCS_PR_CHECK == 'false'
env:
DOCS_REPO: KILTprotocol/docs
PR_NO: ${{ github.event.pull_request.number }}
run: |
DOCS_PRS=$(gh pr list --repo $DOCS_REPO --json number,body,title --jq '.[]')
MATCHING_PR=$(echo "$DOCS_PRS" | jq -r "select(.body | contains(\"#${PR_NO}\") or .title | contains(\"#${PR_NO}\"))")
if [ -z "$MATCHING_PR" ]; then
echo "Please link a docs PR for code PR #${PR_NO} or apply the 'ci-skip-docs-pr' label."
exit 1
else
echo "Matching docs PR found for code PR #${PR_NOPR_NO}."
fi