|
| 1 | +name: Daily PR Recap |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Run at 5pm EST (22:00 UTC, or 21:00 UTC during daylight saving) |
| 6 | + - cron: "0 22 * * *" |
| 7 | + workflow_dispatch: # Allow manual trigger for testing |
| 8 | + |
| 9 | +jobs: |
| 10 | + pr-recap: |
| 11 | + runs-on: blacksmith-4vcpu-ubuntu-2404 |
| 12 | + permissions: |
| 13 | + contents: read |
| 14 | + pull-requests: read |
| 15 | + steps: |
| 16 | + - name: Checkout repository |
| 17 | + uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 1 |
| 20 | + |
| 21 | + - uses: ./.github/actions/setup-bun |
| 22 | + |
| 23 | + - name: Install opencode |
| 24 | + run: curl -fsSL https://opencode.ai/install | bash |
| 25 | + |
| 26 | + - name: Generate daily PR recap |
| 27 | + id: recap |
| 28 | + env: |
| 29 | + OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }} |
| 30 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 31 | + OPENCODE_PERMISSION: | |
| 32 | + { |
| 33 | + "bash": { |
| 34 | + "*": "deny", |
| 35 | + "gh pr*": "allow", |
| 36 | + "gh search*": "allow" |
| 37 | + }, |
| 38 | + "webfetch": "deny", |
| 39 | + "edit": "deny", |
| 40 | + "write": "deny" |
| 41 | + } |
| 42 | + run: | |
| 43 | + TODAY=$(date -u +%Y-%m-%d) |
| 44 | +
|
| 45 | + opencode run -m opencode/claude-sonnet-4-5 "Generate a daily PR activity recap for the OpenCode repository. |
| 46 | +
|
| 47 | + TODAY'S DATE: ${TODAY} |
| 48 | +
|
| 49 | + STEP 1: Gather PR data |
| 50 | + Run these commands to gather PR information: |
| 51 | +
|
| 52 | + # Open PRs with bug fix labels or 'fix' in title |
| 53 | + gh pr list --repo ${{ github.repository }} --state open --search \"fix in:title\" --json number,title,author,labels,createdAt,updatedAt,reviewDecision,isDraft,additions,deletions --limit 100 |
| 54 | +
|
| 55 | + # PRs with high activity (get comments separately to filter bots) |
| 56 | + gh pr list --repo ${{ github.repository }} --state open --json number,title,author,labels,createdAt,updatedAt,reviewDecision,isDraft --limit 100 |
| 57 | +
|
| 58 | + # Recently merged bug fixes |
| 59 | + gh pr list --repo ${{ github.repository }} --state merged --search \"merged:${TODAY} fix in:title\" --json number,title,author,mergedAt --limit 50 |
| 60 | +
|
| 61 | + STEP 2: For high-activity PRs, check comment counts |
| 62 | + For promising PRs, run: |
| 63 | + gh pr view [NUMBER] --repo ${{ github.repository }} --json comments --jq '[.comments[] | select(.author.login != \"copilot-pull-request-reviewer\" and .author.login != \"github-actions\")] | length' |
| 64 | +
|
| 65 | + IMPORTANT: When counting comments/activity, EXCLUDE these bot accounts: |
| 66 | + - copilot-pull-request-reviewer |
| 67 | + - github-actions |
| 68 | +
|
| 69 | + STEP 3: Identify what matters |
| 70 | +
|
| 71 | + **Bug Fixes We Might Miss:** |
| 72 | + - PRs with 'fix' or 'bug' in title that have been open 2+ days |
| 73 | + - Small bug fixes (< 100 lines changed) that are easy to review |
| 74 | + - Bug fixes from community contributors (not core team) |
| 75 | +
|
| 76 | + **High Activity PRs:** |
| 77 | + - PRs with 5+ human comments (excluding bots listed above) |
| 78 | + - PRs with back-and-forth discussion |
| 79 | + - Controversial or complex changes getting attention |
| 80 | +
|
| 81 | + **Quick Wins:** |
| 82 | + - Small PRs (< 50 lines) that are approved or nearly approved |
| 83 | + - Bug fixes that just need a final review |
| 84 | +
|
| 85 | + STEP 4: Generate the recap |
| 86 | + Create a structured recap: |
| 87 | +
|
| 88 | + ===DISCORD_START=== |
| 89 | + **Daily PR Recap - ${TODAY}** |
| 90 | +
|
| 91 | + **Bug Fixes Needing Attention** |
| 92 | + [PRs fixing bugs that might be overlooked - prioritize by age and size] |
| 93 | +
|
| 94 | + **High Activity** (5+ human comments) |
| 95 | + [PRs with significant discussion - exclude bot comments] |
| 96 | +
|
| 97 | + **Quick Wins** (small, ready to merge) |
| 98 | + [Easy PRs that just need a review/merge] |
| 99 | +
|
| 100 | + **Merged Bug Fixes Today** |
| 101 | + [What bug fixes shipped] |
| 102 | + ===DISCORD_END=== |
| 103 | +
|
| 104 | + STEP 5: Format for Discord |
| 105 | + - Use Discord markdown (**, __, etc.) |
| 106 | + - BE EXTREMELY CONCISE - surface what we might miss |
| 107 | + - Use hyperlinked PR numbers with suppressed embeds: [#1234](<https://github.com/${{ github.repository }}/pull/1234>) |
| 108 | + - Include PR author: [#1234](<url>) (@author) |
| 109 | + - For bug fixes, add brief description of what it fixes |
| 110 | + - Show line count for quick wins: \"(+15/-3 lines)\" |
| 111 | + - HARD LIMIT: Keep under 1800 characters total |
| 112 | + - Skip empty sections |
| 113 | + - Focus on PRs that need human eyes |
| 114 | +
|
| 115 | + OUTPUT: Output ONLY the content between ===DISCORD_START=== and ===DISCORD_END=== markers. Include the markers so I can extract it." > /tmp/pr_recap_raw.txt |
| 116 | +
|
| 117 | + # Extract only the Discord message between markers |
| 118 | + sed -n '/===DISCORD_START===/,/===DISCORD_END===/p' /tmp/pr_recap_raw.txt | grep -v '===DISCORD' > /tmp/pr_recap.txt |
| 119 | +
|
| 120 | + echo "recap_file=/tmp/pr_recap.txt" >> $GITHUB_OUTPUT |
| 121 | +
|
| 122 | + - name: Post to Discord |
| 123 | + env: |
| 124 | + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_ISSUES_WEBHOOK_URL }} |
| 125 | + run: | |
| 126 | + if [ -z "$DISCORD_WEBHOOK_URL" ]; then |
| 127 | + echo "Warning: DISCORD_ISSUES_WEBHOOK_URL secret not set, skipping Discord post" |
| 128 | + cat /tmp/pr_recap.txt |
| 129 | + exit 0 |
| 130 | + fi |
| 131 | +
|
| 132 | + # Read the recap |
| 133 | + RECAP_RAW=$(cat /tmp/pr_recap.txt) |
| 134 | + RECAP_LENGTH=${#RECAP_RAW} |
| 135 | +
|
| 136 | + echo "Recap length: ${RECAP_LENGTH} chars" |
| 137 | +
|
| 138 | + # Function to post a message to Discord |
| 139 | + post_to_discord() { |
| 140 | + local msg="$1" |
| 141 | + local content=$(echo "$msg" | jq -Rs '.') |
| 142 | + curl -s -H "Content-Type: application/json" \ |
| 143 | + -X POST \ |
| 144 | + -d "{\"content\": ${content}}" \ |
| 145 | + "$DISCORD_WEBHOOK_URL" |
| 146 | + sleep 1 |
| 147 | + } |
| 148 | +
|
| 149 | + # If under limit, send as single message |
| 150 | + if [ "$RECAP_LENGTH" -le 1950 ]; then |
| 151 | + post_to_discord "$RECAP_RAW" |
| 152 | + else |
| 153 | + echo "Splitting into multiple messages..." |
| 154 | + remaining="$RECAP_RAW" |
| 155 | + while [ ${#remaining} -gt 0 ]; do |
| 156 | + if [ ${#remaining} -le 1950 ]; then |
| 157 | + post_to_discord "$remaining" |
| 158 | + break |
| 159 | + else |
| 160 | + chunk="${remaining:0:1900}" |
| 161 | + last_newline=$(echo "$chunk" | grep -bo $'\n' | tail -1 | cut -d: -f1) |
| 162 | + if [ -n "$last_newline" ] && [ "$last_newline" -gt 500 ]; then |
| 163 | + chunk="${remaining:0:$last_newline}" |
| 164 | + remaining="${remaining:$((last_newline+1))}" |
| 165 | + else |
| 166 | + chunk="${remaining:0:1900}" |
| 167 | + remaining="${remaining:1900}" |
| 168 | + fi |
| 169 | + post_to_discord "$chunk" |
| 170 | + fi |
| 171 | + done |
| 172 | + fi |
| 173 | +
|
| 174 | + echo "Posted daily PR recap to Discord" |
0 commit comments