Skip to content

Periodic PR Reminders #874

Periodic PR Reminders

Periodic PR Reminders #874

Workflow file for this run

name: Periodic PR Reminders
on:
schedule:
- cron: '0 */3 * * *' # Runs every 3 hours
workflow_dispatch: # Allows manual triggering
jobs:
reminder:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Send reminders for PRs with "Ready for review"
run: |
SLACK_WEBHOOK_URL="${{ secrets.SLACK_WEBHOOK_URL }}"
# Fetch PRs with "Ready for review" label
PRS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/issues?labels=Ready%20for%20review&state=open&per_page=100")
PR_COUNT=$(echo $PRS | jq '. | length')
if [ "$PR_COUNT" -eq 0 ]; then
echo "No PRs with 'Ready for review' label found."
exit 0
fi
# Iterate over each PR and send a reminder
for row in $(echo "${PRS}" | jq -r '.[] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
PR_NUMBER=$(_jq '.number')
PR_TITLE=$(_jq '.title')
PR_URL=$(_jq '.html_url')
PR_AUTHOR=$(_jq '.user.login')
PR_DETAILS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/pulls/${PR_NUMBER}")
PR_ADDITIONS=$(echo $PR_DETAILS | jq '.additions')
PR_DELETIONS=$(echo $PR_DETAILS | jq '.deletions')
REPO_NAME=$(echo $PR_DETAILS | jq '.base.repo.full_name')
# Send Slack notification
curl -X POST -H 'Content-type: application/json' \
--data "$(jq -n --arg pr_title "$PR_TITLE" \
--arg pr_url "$PR_URL" \
--arg pr_number "$PR_NUMBER" \
--arg pr_author "$PR_AUTHOR" \
--arg pr_additions "$PR_ADDITIONS" \
--arg pr_deletions "$PR_DELETIONS" \
--arg repo_name "$REPO_NAME" \
'{
text: "*Reminder:* Pull Request \($pr_title) needs a reviewer!",
blocks: [
{
type: "section",
text: {
type: "mrkdwn",
text: ":warning: *Reminder:* Pull Request <\($pr_url)|#\($pr_number)> still needs a reviewer, please take a look!"
}
},
{
type: "section",
text: {
type: "mrkdwn",
text: ":rocket: PR by \($pr_author) needs a review: `+\($pr_additions) -\($pr_deletions)` <\($pr_url)|\($repo_name)#\($pr_number): \($pr_title)>"
}
}
]
}')" \
$SLACK_WEBHOOK_URL
done