Skip to main content

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 TypeDescriptionNotification Sent
openedNew PR createdāœ… Yes
reopenedClosed PR reopenedāœ… Yes
ready_for_reviewDraft PR marked readyāœ… Yes
synchronizeNew commits pushedāŒ No (prevents spam)
closedPR 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 body field
  • 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

šŸ’¬

Documentation Assistant

Ask me anything about the docs

Hi! I'm your documentation assistant. Ask me anything about the docs!

I can help you with:
- Code examples
- Configuration details
- Troubleshooting
- Best practices

Try asking: How do I configure the API?
09:31 AM