Skip to content

PR Tracking and Attention Report #54

PR Tracking and Attention Report

PR Tracking and Attention Report #54

name: PR Tracking and Attention Report
on:
schedule:
# Run daily at 9am UTC
- cron: '0 9 * * *'
workflow_dispatch:
jobs:
track-prs:
runs-on: ubuntu-latest
steps:
- name: Checkout .github repo
uses: actions/checkout@v4
- name: Create or checkout pr-tracking branch
run: |
git fetch origin pr-tracking:pr-tracking 2>/dev/null || git checkout -b pr-tracking
git checkout pr-tracking
- name: Analyze PRs and Generate Reports
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p pr-tracking
# Get team members (maintainers)
# GITHUB_TOKEN doesn't have permission to read team members
# Using hardcoded list of automation-proddev team members
# Update this list when team membership changes
team_members="gschueler jtobard ltamaster carlosrfranco fdevans jsboak ronaveva jayas006 Jesus-Osuna-M smartinellibenedetti gbhutani-pd"
echo "Team members count: $(echo $team_members | wc -w)"
echo "# PR Report - $(date +%Y-%m-%d)" > pr-count.md
echo "" >> pr-count.md
echo "## Summary" >> pr-count.md
echo "" >> pr-count.md
# Get all repos in the org
repos=$(gh repo list rundeck-plugins --limit 100 --json name -q '.[].name')
total_prs=0
repos_with_prs=0
needs_attention=0
echo "| Repository | Open PRs | Needs Attention |" >> pr-count.md
echo "|------------|----------|-----------------|" >> pr-count.md
# Temp file for attention details
> attention-details.md
for repo in $repos; do
# Check if repo is archived
is_archived=$(gh repo view rundeck-plugins/$repo --json isArchived -q '.isArchived')
if [ "$is_archived" = "true" ]; then
continue
fi
# Count total PRs
count=$(gh pr list --repo rundeck-plugins/$repo --state open --json number -q 'length')
if [ "$count" -eq 0 ]; then
continue
fi
# Analyze which PRs need attention
repo_attention=0
prs=$(gh pr list --repo rundeck-plugins/$repo --state open --json number,title,updatedAt,author --limit 50)
pr_count=$(echo "$prs" | jq 'length')
for ((i=0; i<pr_count; i++)); do
pr=$(echo "$prs" | jq -r ".[$i]")
pr_number=$(echo "$pr" | jq -r '.number')
pr_title=$(echo "$pr" | jq -r '.title')
pr_updated=$(echo "$pr" | jq -r '.updatedAt')
pr_author=$(echo "$pr" | jq -r '.author.login')
# Get last comment and review, excluding Copilot
last_comment=$(gh api "repos/rundeck-plugins/$repo/issues/$pr_number/comments" --paginate -q '.[] | select(.user.login != "copilot-pull-request-reviewer[bot]") | {user: .user.login, created_at: .created_at}' | jq -s '.[-1]')
last_review=$(gh api "repos/rundeck-plugins/$repo/pulls/$pr_number/reviews" --paginate -q '.[] | select(.user.login != "copilot-pull-request-reviewer[bot]") | {user: .user.login, submitted_at: .submitted_at}' | jq -s '.[-1]')
# Determine most recent activity
comment_time=$(echo "$last_comment" | jq -r '.created_at // empty')
review_time=$(echo "$last_review" | jq -r '.submitted_at // empty')
if [ -z "$comment_time" ] && [ -z "$review_time" ]; then
# No comments or reviews, use PR author
last_actor="$pr_author"
last_event="opened"
elif [ -z "$review_time" ] || [[ "$comment_time" > "$review_time" ]]; then
# Comment is more recent
last_actor=$(echo "$last_comment" | jq -r '.user')
last_event="commented"
else
# Review is more recent
last_actor=$(echo "$last_review" | jq -r '.user')
last_event="reviewed"
fi
# Check if last actor is community (not in team)
if echo " $team_members " | grep -q " $last_actor "; then
is_community=false
else
is_community=true
fi
# Debug output
echo "DEBUG: $repo #$pr_number - last_actor='$last_actor' is_community='$is_community'"
# Flag if community was last to act
if [ "$is_community" = "true" ]; then
repo_attention=$((repo_attention + 1))
# Save details for attention section
echo "- **$repo #$pr_number**: $pr_title" >> attention-details.md
echo " - Last activity: $last_event by @$last_actor" >> attention-details.md
echo " - Link: https://github.com/rundeck-plugins/$repo/pull/$pr_number" >> attention-details.md
echo "" >> attention-details.md
fi
done
# Add to summary table
if [ "$repo_attention" -gt 0 ]; then
echo "| [$repo](https://github.com/rundeck-plugins/$repo/pulls) | $count | **$repo_attention** |" >> pr-count.md
else
echo "| [$repo](https://github.com/rundeck-plugins/$repo/pulls) | $count | 0 |" >> pr-count.md
fi
total_prs=$((total_prs + count))
repos_with_prs=$((repos_with_prs + 1))
needs_attention=$((needs_attention + repo_attention))
done
echo "" >> pr-count.md
echo "**Total Open PRs:** $total_prs across $repos_with_prs repositories" >> pr-count.md
echo "**PRs Needing Attention:** $needs_attention" >> pr-count.md
# Add attention details section
if [ "$needs_attention" -gt 0 ]; then
echo "" >> pr-count.md
echo "---" >> pr-count.md
echo "" >> pr-count.md
echo "## PRs Needing Attention" >> pr-count.md
echo "" >> pr-count.md
echo "PRs where community has most recent activity (comment or commit):" >> pr-count.md
echo "" >> pr-count.md
cat attention-details.md >> pr-count.md
fi
# Create CSV with headers if it doesn't exist
if [ ! -f pr-tracking/history.csv ]; then
echo "date,total_prs,repos_with_prs,needs_attention" > pr-tracking/history.csv
fi
# Check if today's entry already exists, update or append
today=$(date +%Y-%m-%d)
if grep -q "^$today," pr-tracking/history.csv; then
# Update existing entry - remove old line and append new
grep -v "^$today," pr-tracking/history.csv > pr-tracking/history.csv.tmp
mv pr-tracking/history.csv.tmp pr-tracking/history.csv
echo "$today,$total_prs,$repos_with_prs,$needs_attention" >> pr-tracking/history.csv
else
# Append new entry
echo "$today,$total_prs,$repos_with_prs,$needs_attention" >> pr-tracking/history.csv
fi
# Save markdown report (overwrite if exists)
cp pr-count.md pr-tracking/$today.md
cat pr-count.md
- name: Commit and Push to pr-tracking branch
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add pr-tracking/
git commit -m "Daily PR report: $(date +%Y-%m-%d)" || echo "No changes"
git push origin pr-tracking