PR Review Reminder Workflow (pr-review-reminder.yaml)
The PR Review Reminder Workflow automatically sends notifications to the team when pull requests are opened, reopened, or marked ready for review. It helps maintain development velocity by ensuring PRs don't go unnoticed and facilitates timely code reviews.
š Overviewā
- File:
.github/workflows/pr-review-reminder.yaml - Purpose: Team notification for PR reviews
- Trigger: PR state changes (opened, reopened, ready_for_review)
- Features: Smart filtering, rich notifications, webhook integration
- Platform: Ubuntu with Node.js runtime
š Trigger Eventsā
on:
pull_request:
types: [opened, reopened, ready_for_review]
Trigger Scenariosā
| Event Type | Description | Notification Sent |
|---|---|---|
opened | New PR created | ā Yes |
reopened | Closed PR reopened | ā Yes |
ready_for_review | Draft PR marked ready | ā Yes |
synchronize | New commits pushed | ā No (prevents spam) |
closed | PR closed/merged | ā No |
š PR Information Extractionā
Data Collectionā
# Extract PR metadata
PR_TITLE="${{ github.event.pull_request.title }}"
PR_LINK="https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}"
PR_CREATOR="${{ github.event.pull_request.user.login }}"
# Process labels with proper JSON handling
cat > /tmp/pr_labels.json << 'ENDOFJSON'
${{ toJSON(github.event.pull_request.labels) }}
ENDOFJSON
Label Processingā
# Format labels for display
if [ "$(jq 'length' /tmp/pr_labels.json)" -eq 0 ]; then
labels="No labels"
else
labels=$(jq -r 'map("⢠" + .name) | join("\n")' /tmp/pr_labels.json)
fi
š« Smart Filteringā
Skip Conditionsā
The workflow intelligently skips notifications for:
# Skip draft PRs
if [ "${{ github.event.pull_request.draft }}" = "true" ]; then
echo "Skipping notification - PR is in draft state"
exit 0
fi
# Skip closed/merged PRs
if [ "${{ github.event.pull_request.merged }}" = "true" ] ||
[ "${{ github.event.pull_request.state }}" = "closed" ]; then
echo "Skipping notification - PR is already merged or closed"
exit 0
fi
Filtering Benefitsā
- Reduced noise: No notifications for draft PRs
- Relevant timing: Only notify when review is actually needed
- Status awareness: Skip already processed PRs
- Team efficiency: Focus attention on actionable items
šØ Notification Systemā
Webhook Configurationā
env:
WEBHOOK_URL: ${{ vars.PR_REMINDER_WEBHOOK_URL }}
Message Formattingā
// JSON-escaped message creation
message=$(cat << EOF | jq -Rs .
š **Pull Request #${{ github.event.pull_request.number }} Review Required**
**Repository:** ${{ github.repository }}
**Title:** ${{ steps.pr_info.outputs.title }}
**Creator:** _${{ steps.pr_info.outputs.creator }}_
**Labels:**
${{ steps.pr_info.outputs.labels }}
š **Link:** ${{ steps.pr_info.outputs.link }}
EOF
)
Webhook Deliveryā
// Node.js fetch implementation
async function sendWebhook() {
try {
const res = await fetch('$WEBHOOK_URL', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ body: ${message} })
});
const text = await res.text();
console.log(text);
return text;
} catch (err) {
console.error(err);
process.exit(1);
}
}
š¬ Notification Contentā
Message Structureā
š **Pull Request #123 Review Required**
**Repository:** DashClicks-LLC/Back-End
**Title:** Add new authentication middleware
**Creator:** _john-doe_
**Labels:**
⢠enhancement
⢠backend
⢠security
š **Link:** https://github.com/DashClicks-LLC/Back-End/pull/123
Rich Informationā
Each notification includes:
- PR Number: Direct reference for team communication
- Repository: Clear context for multi-repo organizations
- Title: PR purpose and scope
- Creator: Who created the PR for context
- Labels: Categories and priority indicators
- Direct Link: One-click access to the PR
š§ Configurationā
Required Variablesā
# Repository variable (not secret)
PR_REMINDER_WEBHOOK_URL: https://hooks.slack.com/services/...
Webhook Destinationsā
Common integration targets:
- Slack: Team channels with rich formatting
- Microsoft Teams: Collaborative workspace notifications
- Discord: Development community servers
- Custom webhooks: Internal notification systems
Variable Securityā
Why use Variables vs Secrets?
- Variables: For non-sensitive configuration (webhook URLs)
- Public repositories: Variables are visible to contributors
- Secrets: For sensitive data (authentication tokens)
- Flexibility: Easy to update without code changes
š Security Considerationsā
Webhook Securityā
# Webhook URL validation
if [ -z "$WEBHOOK_URL" ]; then
echo "Error: WEBHOOK_URL is not set"
exit 1
fi
Error Handlingā
# Comprehensive error handling
status_code=${PIPESTATUS[0]}
if [ "$status_code" -ne 0 ]; then
echo "Error: Webhook request failed"
echo "Response: $response"
exit 1
fi
Best Practicesā
- URL Validation: Always check webhook URL exists
- Error Logging: Capture and log webhook failures
- Rate Limiting: Respect destination service limits
- Retry Logic: Implement retry for transient failures
šÆ Integration Examplesā
Slack Integrationā
{
"body": "š **Pull Request #123 Review Required**\n\n**Repository:** DashClicks-LLC/Back-End\n**Title:** Add authentication middleware\n**Creator:** _john-doe_\n**Labels:**\n⢠enhancement\n⢠security\n\nš **Link:** https://github.com/DashClicks-LLC/Back-End/pull/123"
}
Microsoft Teamsā
{
"body": "š **Pull Request Review Required**\n\nA new pull request needs your attention:\n\n**PR #123**: Add authentication middleware\n**Repository**: DashClicks-LLC/Back-End\n**Author**: john-doe\n\n[View Pull Request](https://github.com/DashClicks-LLC/Back-End/pull/123)"
}
Discordā
{
"body": "š **New PR Review Request**\n\n**#123**: Add authentication middleware\n**Repo**: DashClicks-LLC/Back-End\n**By**: @john-doe\n**Labels**: enhancement, security\n\n[Review Here](https://github.com/DashClicks-LLC/Back-End/pull/123)"
}
š Workflow Analyticsā
Notification Metricsā
Track notification effectiveness:
- Delivery rate: Successful webhook deliveries
- Response time: Time from PR creation to first review
- Review completion: PRs reviewed within SLA
- Team engagement: Active reviewers and response patterns
Performance Monitoringā
# Execution time tracking
start_time=$(date +%s)
# ... workflow execution ...
end_time=$(date +%s)
echo "Notification sent in $((end_time - start_time)) seconds"
š Notification Configurationā
Webhook Requirementsā
The workflow requires:
- PR_REMINDER_WEBHOOK_URL: Repository variable containing webhook endpoint
- Webhook format: JSON payload with
bodyfield - Supported destinations: Slack, Microsoft Teams, Discord, custom webhooks
Message Contentā
Each notification includes:
- PR number and title: Basic identification
- Repository name: Context for multi-repo setups
- Creator username: PR author information
- Labels: Formatted label list or "No labels"
- Direct link: GitHub PR URL for quick access
š Related Workflowsā
- lint-check.yaml - Quality checks before review requests
- unit-tests.yml - Automated testing for PR validation