---
description: Creates weekly summary of issue activity including trends, charts, and insights every Monday

timeout-minutes: 20

on:
  schedule: weekly on monday
  workflow_dispatch:

permissions:
  contents: read # required by the `repos` toolset (see the github tools block below)
  issues: read
  copilot-requests: write

network:
  allowed:
    - defaults

tools:
  edit:
  bash:
    - "*"
  github:
    toolsets:
      - issues
      # Required by the MCP gateway's github guard: it resolves repository visibility
      # through `search_repositories`, which lives in the `repos` toolset. Without it the
      # call fails and the guard fails closed, labelling every issue `secrecy: private`
      # and filtering the whole response out of the agent's view.
      - repos
    min-integrity: none # This workflow is allowed to examine and comment on any issues or PRs

safe-outputs:
  messages:
    footer: "> 🤖 **Automated content by GitHub Copilot.** Generated by the [{workflow_name}]({agentic_workflow_url}) workflow.{ai_credits_suffix} · [◷]({history_link})"
  noop:
    report-as-issue: false
  # Deliberately a single safe output. The agent harness arms a 20s idle watchdog as soon
  # as the first safe output is emitted, and it terminates the agent while it is still
  # composing the report. Charts are therefore rendered as ASCII inside the discussion
  # body instead of being uploaded as image assets.
  create-discussion:
    title-prefix: "[weekly-issue-activity] "
    category: "audits"
    close-older-discussions: true
source: githubnext/agentics/workflows/weekly-issue-activity.md@main
---

# Weekly Issue Summary

Create a comprehensive weekly summary of issue activity for repository ${{ github.repository }}.

## Step 1: Collect Issue Data

Use GitHub API tools to gather two different windows — the weekly activity chart spans 12 weeks, so a 30-day fetch cannot populate it:

1. **Issue Activity Data** (last **12 weeks**)  -  Count of issues opened and closed per week, and the running open count
2. **Issue Resolution Data** (last **30 days**)  -  Average time to close issues, distribution of issue lifespans, breakdown by label

Use the GitHub toolset to query issues filtered by `created` and `closed` dates, paginating until you have covered the full 12 weeks. If the 12-week history is only partially available, chart what you have and say so rather than presenting a truncated series as complete.

## Step 2: Compute Trends and Render Charts

Do all number crunching **before** emitting any safe output: as soon as the first safe output is emitted the harness starts a short idle watchdog and will terminate the agent mid-run.

`/usr/bin/python3` is available with the standard library (`json`, `csv`, `datetime`, `statistics`) — use it via bash for aggregation. Do not `pip install` anything: the sandbox's default `python3` is PyPy from the runner tool cache and building wheels there will exhaust the workflow timeout.

Save the aggregated series to files so you can re-read them while composing the report:

- `/tmp/gh-aw/agent/data/issue_activity.csv` with columns `date,opened,closed,open_total` (last 12 weeks)
- `/tmp/gh-aw/agent/data/issue_resolution.csv` with columns `date,avg_days,median_days` (last 30 days)

Render both series as ASCII charts to embed directly in the discussion body.

### Chart 1: Issue Activity Trends

Weekly opened vs. closed counts plus the running open total, as aligned bar rows or a table with sparklines.

### Chart 2: Issue Resolution Time Trends

Average and median days-to-close over the last 30 days, as a sparkline pair.

### ASCII Chart Rules

- Always wrap a chart in a fenced code block; use spaces, never tabs, and never ANSI escapes
- Keep width under 80 characters (40–60 is ideal for GitHub mobile) and height under 12 rows
- Prefer these glyphs: `█ ▇ ▆ ▅ ▄ ▃ ▂ ▁` and `│ ─ ┌ ┐ └ ┘`; fall back to `# * - |`
- Pad labels to equal width so bars line up, and keep labels short
- Normalize bars to the available width and clamp outliers so one spike doesn't flatten the rest
- Optimize for a reader who glances for two seconds: readability > alignment > compactness > precision

## Step 3: Create Weekly Discussion

Create a discussion with the title format: `Weekly Summary - [YYYY-MM-DD]`. This is the **only** safe output this workflow emits, so have the complete body ready before calling `create_discussion`.

### Formatting Guidelines

- Use `###` for main sections, `####` for subsections (discussion title is the h1)
- Wrap long lists in `<details><summary>` collapsible sections
- Keep critical information (overview, trends, statistics, recommendations) always visible
- Keep optional detail (full issue lists, verbose breakdowns) in collapsible sections

### Discussion Structure

```markdown
### 📊 Weekly Overview

[1–2 paragraphs: total issues opened and closed this week, how that compares to the previous week, key theme or pattern in the issues]

### 📈 Issue Activity Trends

#### Weekly Activity Patterns

```text
[ASCII chart: issues opened vs. closed per week over the last 12 weeks, plus running open total]
```

[2–3 sentences: describe the trend  -  are issues accumulating, being resolved quickly, or holding steady?]

#### Resolution Time Analysis

```text
[ASCII chart: average and median days to close over the last 30 days]
```

[2–3 sentences: how quickly are issues being resolved? improving or slowing down?]

### 🔑 Key Trends

[Bullet list of 3–5 notable patterns: common issue types, label distribution, new contributors filing issues, recurring topics, etc.]

### 📋 Summary Statistics

| Metric | This Week | Last Week | Trend |
|--------|-----------|-----------|-------|
| Issues Opened | X | X | ↑/↓/→ |
| Issues Closed | X | X | ↑/↓/→ |
| Currently Open | X | X | ↑/↓/→ |
| Avg Close Time | X days | X days | ↑/↓/→ |

<details>
<summary><b>Full Issue List (This Week)</b></summary>

[Numbered list of all issues opened this week with title, number, author, labels]

</details>

### 💡 Recommendations for Upcoming Week

[3–5 actionable suggestions: which issues to prioritize, patterns that suggest backlog growth, labels that need attention, etc.]
```

## Step 4: Notes

- If fewer than 7 days of data are available, render charts with the available data and note the limited range
- If no issues exist this week, still create a discussion noting the quiet week
- Always create the discussion, even if some metrics could not be computed (omit those sections and explain why)
