Skip to content

docs: fix dead links failing the daily link checker #231

docs: fix dead links failing the daily link checker

docs: fix dead links failing the daily link checker #231

name: Request TW review by label
on:
# Runs from master with a write token, so fork PRs work too. Never check out PR code here.
pull_request_target:
types: [opened, labeled, ready_for_review]
paths:
- 'sources/**'
- 'apify-api/**'
permissions:
pull-requests: write
jobs:
request_review:
name: Request TW review
# Like CODEOWNERS: no requests on drafts or closed PRs
if: github.event.action != 'opened' && github.event.pull_request.state == 'open' && !github.event.pull_request.draft
runs-on: ubuntu-latest
steps:
- name: Request the writer for the team label
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
# The new label, or all labels when a draft becomes ready
LABELS: ${{ github.event.action == 'labeled' && github.event.label.name || join(github.event.pull_request.labels.*.name, ' ') }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
run: |
set -f # label names are not globs
reviewers=""
for label in $LABELS; do
# Team labels → R&D group → technical writer
case "$label" in
t-core-services|t-infra|t-console|t-unblocking) reviewer=TC-MO ;; # Foundation
t-publishers|t-billing|t-tooling|t-builders) reviewer=szaganek ;; # Creators
t-acquisition|t-growth|t-ai|t-integrations|t-discovery) reviewer=marcel-rbro ;; # Integrators
*) continue ;;
esac
# GitHub rejects a review request from the PR author
[ "$reviewer" = "$PR_AUTHOR" ] && continue
case ",$reviewers," in
*",$reviewer,"*) ;;
*) reviewers="${reviewers:+$reviewers,}$reviewer" ;;
esac
done
if [ -z "$reviewers" ]; then
echo "No writer to request for: $LABELS"
exit 0
fi
gh pr edit "$PR_NUMBER" --add-reviewer "$reviewers"
fallback:
name: Request triage TW when no writer is set
# PRs from writers and bots need no triage
if: >-
(github.event.action == 'opened' || github.event.action == 'ready_for_review')
&& !github.event.pull_request.draft
&& github.event.pull_request.user.type != 'Bot'
&& !contains(fromJSON('["TC-MO", "szaganek", "marcel-rbro"]'), github.event.pull_request.user.login)
runs-on: ubuntu-latest
steps:
- name: Request TC-MO if no writer was requested
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
# The PR toolkit adds the team label 20-30 s after the PR is ready; give the label job time to run
sleep 90
writers=$(gh pr view "$PR_NUMBER" --json reviewRequests,reviews,state,isDraft --jq '
if .state != "OPEN" or .isDraft then "skip"
else [.reviewRequests[].login, .reviews[].author.login]
| map(select(. == "TC-MO" or . == "szaganek" or . == "marcel-rbro")) | join(",")
end')
if [ -n "$writers" ]; then
echo "Nothing to do: $writers"
exit 0
fi
gh pr edit "$PR_NUMBER" --add-reviewer TC-MO