ci: docs pr checker #7
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |