Skip to content

PR Tracking and Attention Report #20

PR Tracking and Attention Report

PR Tracking and Attention Report #20

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
# 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/event
timeline=$(gh api "repos/rundeck-plugins/$repo/issues/$pr_number/timeline" --paginate -q '.[] | select(.event == "commented" or .event == "committed") | {event: .event, actor: (.actor.login // .author.login // .committer.login), created_at: .created_at}' | jq -s '.')
if [ "$(echo "$timeline" | jq 'length')" -eq 0 ]; then
# No activity yet, check if author is community
last_actor="$pr_author"
last_event="opened"
if echo " $team_members " | grep -q " $pr_author "; then
is_community=false
else
is_community=true
fi
else
# Get most recent activity
last_activity=$(echo "$timeline" | jq -r '.[-1]')
last_actor=$(echo "$last_activity" | jq -r '.actor')
last_event=$(echo "$last_activity" | jq -r '.event')
# 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
fi
# 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 (is_team: false)" >> attention-details.md
echo " - Link: https://github.com/rundeck-plugins/$repo/pull/$pr_number" >> attention-details.md
echo "" >> attention-details.md
else
# Debug: log maintainer activity
echo "DEBUG: $repo #$pr_number - $last_actor is a team member, skipping"
fi
done
# Add to summary table
if [ "$repo_attention" -gt 0 ]; then
echo "| $repo | $count | **$repo_attention** |" >> pr-count.md
else
echo "| $repo | $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