Skip to content
Merged
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated reports from local testing
report.md
weekly-report.md
comment-template.md
*.md.bak

# macOS
Expand Down
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,46 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- **Comment summary template**: Auto-generate an editable highlights template from merged PR data
- New `--summary-template` CLI flag and `summary-template` action input
- New `--summary-template-file=FILE` CLI flag and `summary-template-file` action input
- Collects merged PR titles, URLs, authors, and labels during report generation
- Groups PRs by repository with placeholder sections for human curation
- New `comment-template` action output for downstream workflow steps
- Labels from PRs are included to aid thematic categorization
- Auto-detects contributors from merged PRs (filters bots and Copilot)
- Uses markdown link format for clean GitHub rendering
- See [Comment Summary Template docs](docs/comment-summary-template.md) for details
- **Release tracking in summary template**: Repos that publish releases now show them in the template
- Fetches releases published in the report date range via GitHub API
- Displays a single releases table at the top of the template (omitted if no releases)
- Table columns: Repository, Release (name/tag with link), Date
- Sorted by publication date (newest first)
- Works for both organization repos and external tracked repos
- Helps summarize important milestones alongside PR activity
- **Releases column in main report**: Include release activity directly in the primary report table
- Adds a **Releases** column to the main activity table for each repository
- Counts non-draft releases published in the report date range and includes them in the totals row
- Clickable link to repo releases page when count > 0
- Keeps release metrics alongside issues, PRs, and commits for a unified overview

### Fixed
- **Corrupted documentation**: Rewrote `docs/testing.md` to remove duplicated/interleaved content and restore a clean testing guide
- **Corrupted tests README**: Rewrote `tests/README.md` to remove duplicated content and ensure it only references existing test files
- **CLI error message**: Changed misleading `ERROR: GITHUB_OUTPUT environment variable not set!` to a debug message in CLI mode (GITHUB_OUTPUT is only relevant in GitHub Actions)
- **Hyperlinks documentation**: Fixed `docs/hyperlinks.md` overview that incorrectly said "metrics greater than 1" when the actual behavior is "metrics greater than 0"
- **`set -e` safety for API calls**: Restructured all `api_call` assignments to use `if var=$(api_call ...); then` pattern so that API failures are handled gracefully instead of aborting the script
- **Date formatting in releases table**: Use non-zero-padded day format (`Feb 5` instead of `Feb 05`) for consistent display with documentation examples
- **Clickable links comment**: Fixed comment that said "if > 1" to match actual `format_metric()` behavior of linking when count is > 0

### Changed
- **CONTRIBUTING.md**: Updated from generic Python template (referenced `pip install`, `pytest`, PEP 8) to accurate shell-project instructions with correct tooling (`bash`, `curl`, `jq`) and test commands
- **Argument parsing**: Removed no-op `shift` statements inside `for arg in "$@"` loop in `generate-report.sh` (shift has no effect inside a for loop)
- **Copilot instructions**: Added `.tmp/` file staging guidelines to prevent heredoc/shell escaping issues
- **`.gitignore`**: Added `.tmp/` working directory for file staging
- **Debug output**: All debug messages are now gated behind `--debug` CLI flag / `debug` action input (silent by default)
- **Comment template docs**: Softened wording from "all merged PRs" to "merged PRs" and documented the 100-item-per-page API limit

## [2.2.0] - 2025-10-23

Expand Down
35 changes: 31 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ A powerful GitHub Action that generates comprehensive activity reports across Gi

- **📊 Comprehensive Analytics**: Issues, PRs, commits, and activity summaries
- **🔗 Clickable Metrics**: Numbers > 0 link directly to GitHub search results for quick navigation
- **📝 Comment Summary Template**: Auto-generates an editable highlights template with merged PR details and labels
- **🌐 External Repository Tracking**: Monitor repositories outside your primary organization
- **⚡ Smart Activity Detection**: Captures ALL repository activity (commits, issues, PRs, updates) with intelligent filtering
- **🔄 Complete Coverage**: Handles organizations with hundreds of repositories via pagination
Expand Down Expand Up @@ -86,6 +87,12 @@ export GITHUB_TOKEN=ghp_xxxxx
# Track external repositories (from other organizations)
./generate-report.sh --token=ghp_xxxxx --track-external-repos=executablebooks/sphinx-proof,executablebooks/sphinx-exercise

# Generate report with comment summary template
./generate-report.sh --token=ghp_xxxxx --summary-template

# Custom summary template output file
./generate-report.sh --token=ghp_xxxxx --summary-template --summary-template-file=highlights.md

# View the generated report
cat report.md
```
Expand All @@ -105,6 +112,9 @@ cat report.md
- `--exclude=REPOS` - Comma-separated list of repos or regex patterns to exclude (e.g., `repo1,lecture-.*\.notebooks`)
- `--track-external-repos=LIST` - Comma-separated list of external repos to track (format: `org/repo`, e.g., `executablebooks/sphinx-proof,executablebooks/sphinx-exercise`)
- `--delay=SECONDS` - Delay between API calls (default: 0)
- `--summary-template` - Generate a comment summary template with merged PR details
- `--summary-template-file=FILE` - Output filename for summary template (default: `comment-template.md`)
- `--debug` - Enable verbose debug output

The report is saved to `report.md` (or your specified output file) in the current directory.

Expand All @@ -118,13 +128,17 @@ The report is saved to `report.md` (or your specified output file) in the curren
| `exclude-repos` | Comma-separated list of repository names or regex patterns to exclude (e.g., `repo1,lecture-.*\.notebooks`) | No | `''` |
| `track-external-repos` | Comma-separated list of external repositories to track (format: `org/repo`, e.g., `executablebooks/sphinx-proof,executablebooks/sphinx-exercise`) | No | `''` |
| `api-delay` | Delay in seconds between API calls to avoid rate limits (0 = no delay) | No | `0` |
| `summary-template` | Generate a comment summary template with merged PR details (`true`/`false`) | No | `false` |
| `summary-template-file` | Output filename for the comment summary template | No | `comment-template.md` |
| `debug` | Enable verbose debug output (`true`/`false`) | No | `false` |

## Outputs

| Output | Description |
|--------|-------------|
| `report-content` | The full generated report content |
| `report-summary` | A brief summary of the report metrics |
| `comment-template` | The generated comment summary template content (when `summary-template` is enabled) |

## How It Works

Expand Down Expand Up @@ -171,23 +185,35 @@ jobs:
weekly-report:
runs-on: ubuntu-latest
steps:
# Step 1: Generate the report (our action)
# Step 1: Generate the report and comment summary template
- name: Generate weekly report
uses: QuantEcon/action-weekly-report@v2 # Always uses latest v2.x.x release
uses: QuantEcon/action-weekly-report@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
organization: 'QuantEcon'
track-external-repos: 'executablebooks/sphinx-proof,executablebooks/sphinx-exercise'
summary-template: 'true'

# Step 2: Create issue with report (separate action - optional)
# Step 2: Create issue from report
- name: Create issue from report
id: create-issue
uses: peter-evans/create-issue-from-file@v4
with:
title: Weekly Activity Report
content-filepath: weekly-report.md # Action outputs to weekly-report.md
content-filepath: weekly-report.md
labels: report, automated

# Step 3: Post the comment summary template on the new issue
- name: Post comment summary template
if: hashFiles('comment-template.md') != ''
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ steps.create-issue.outputs.issue-number }}
body-path: comment-template.md
```

**How it works:** Step 1 generates both `weekly-report.md` and `comment-template.md`. Step 2 creates the issue. Step 3 posts the template as the first comment on that issue — ready for a maintainer to edit into a curated highlights summary.

**Note:** The action outputs to `weekly-report.md` by default. In CLI mode, it uses `report.md`.

## Report Format
Expand All @@ -207,6 +233,7 @@ For large organizations, use the `api-delay` parameter to add delays between req
## Documentation

- **[Testing Guide](docs/testing.md)** - How to test and validate the action
- **[Comment Summary Template](docs/comment-summary-template.md)** - Auto-generated highlights from merged PRs
- **[Technical Details](docs/improvements.md)** - Implementation details
- **[Validation Examples](docs/validation.md)** - Real-world validation
- **[Release Notes](docs/releases/)** - Version-specific changes
Expand Down
20 changes: 19 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ inputs:
description: 'Delay in seconds between API calls to avoid rate limits (0 = no delay)'
required: false
default: '0'
summary-template:
description: 'Generate a comment summary template with merged PR details (true/false)'
required: false
default: 'false'
summary-template-file:
description: 'Output filename for the comment summary template'
required: false
default: 'comment-template.md'
debug:
description: 'Enable verbose debug output (true/false)'
required: false
default: 'false'

outputs:
report-content:
Expand All @@ -34,6 +46,9 @@ outputs:
report-summary:
description: 'A brief summary of the report metrics'
value: ${{ steps.generate.outputs.report-summary }}
comment-template:
description: 'The generated comment summary template content (when summary-template is enabled)'
value: ${{ steps.generate.outputs.comment-template }}

runs:
using: 'composite'
Expand All @@ -48,4 +63,7 @@ runs:
INPUT_OUTPUT_FORMAT: ${{ inputs.output-format }}
INPUT_EXCLUDE_REPOS: ${{ inputs.exclude-repos }}
INPUT_TRACK_EXTERNAL_REPOS: ${{ inputs.track-external-repos }}
INPUT_API_DELAY: ${{ inputs.api-delay }}
INPUT_API_DELAY: ${{ inputs.api-delay }}
INPUT_SUMMARY_TEMPLATE: ${{ inputs.summary-template }}
INPUT_SUMMARY_TEMPLATE_FILE: ${{ inputs.summary-template-file }}
INPUT_DEBUG: ${{ inputs.debug }}
7 changes: 7 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- [Testing Guide](testing.md) - How to test and validate the action
- [Hyperlink Feature](hyperlinks.md) - Interactive metrics with clickable links
- [Comment Summary Template](comment-summary-template.md) - Auto-generated highlights from merged PRs
- [Technical Details](improvements.md) - Implementation and architecture
- [Validation](validation.md) - Real-world examples and verification
- [Release Notes](releases/) - Version history and changes
Expand All @@ -24,6 +25,12 @@
- URL formats and destinations
- Usage examples

**[Comment Summary Template](comment-summary-template.md)**
- Auto-generate highlights from merged PR data
- Label-aware categorization
- Editable template workflow
- Action outputs for downstream steps

### Technical Documentation

**[Implementation Details](improvements.md)**
Expand Down
169 changes: 169 additions & 0 deletions docs/comment-summary-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
# Comment Summary Template

The comment summary template feature auto-generates an editable markdown template containing merged PR details from the report period. This helps write the "highlights" comment that accompanies each activity report.

> **Note:** The template includes up to 100 merged PRs and 100 releases per repository (the GitHub API default page size). For most repositories and weekly report windows, this covers all activity.

## Background

Activity reports generated by this action contain a metrics table (issues, PRs, commits). The accompanying comment — written by a maintainer — provides high-level context about what was accomplished. This feature bridges the gap by collecting the raw PR data needed to write that comment.

See [QuantEcon/meta#280](https://github.com/QuantEcon/meta/issues/280) for an example of a report with a hand-written highlights comment.

## Usage

### CLI

```bash
# Generate report with comment summary template
./generate-report.sh --token=ghp_xxxxx --summary-template

# Custom output filename
./generate-report.sh --token=ghp_xxxxx --summary-template --summary-template-file=highlights.md
```

### GitHub Action

```yaml
- name: Generate activity report
uses: QuantEcon/action-weekly-report@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
summary-template: 'true'
summary-template-file: 'comment-template.md'
```

## Output Format

The template is written to `comment-template.md` (default) and contains:

1. **Placeholder summary** — Editable topic bullets for high-level themes
2. **Releases table** — All releases published in the period in a single table (omitted if none)
3. **Merged PRs by repository** — Merged PRs with title, URL, labels, and author
4. **Contributor acknowledgement** — Auto-generated from PR authors (bots and Copilot excluded)

### Example Output

```markdown
**High Level Summary:**

1. **[Topic 1]** _Add a high-level summary of work in this area._
2. **[Topic 2]** _Add another thematic summary._

---

## 📦 Releases

| Repository | Release | Date |
|------------|---------|------|
| lecture-python.myst | [publish-2026feb19b](https://github.com/.../publish-2026feb19b) | Feb 19 |
| quantecon-book-theme | [v0.17.0](https://github.com/.../v0.17.0) | Feb 19 |
| QuantEcon.py | [v0.11.0](https://github.com/.../v0.11.0) | Feb 15 |

**lecture-python.myst:**
- [Update consumer problem lecture](https://github.com/QuantEcon/lecture-python.myst/pull/757) [maintenance] (@HumphreyYang)
- [Fix typo in GDP lecture](https://github.com/QuantEcon/lecture-python.myst/pull/756) (@contributor)

**quantecon-book-theme:**
- [Major refactor for responsiveness](https://github.com/QuantEcon/quantecon-book-theme/pull/335) [infrastructure, priority: high] (@mmcky)

---

thanks @HumphreyYang, @mmcky, and @contributor for all your contributions.
```

## How Labels Help

When PRs have labels (e.g., `maintenance`, `infrastructure`, `bug`, `priority: high`), they appear in brackets next to each PR. This makes it easier to:

- **Group by theme** — Quickly identify which PRs relate to maintenance vs. new features
- **Prioritize highlights** — Spot high-priority work at a glance
- **Categorize** — Reorganize the flat per-repo list into thematic sections

For maximum benefit, use standardized labels across repositories. See [QuantEcon/meta#178](https://github.com/QuantEcon/meta/issues/178) for the labels standardization initiative.

## Workflow

### Automated (GitHub Actions)

The template can be auto-posted as a comment on the activity report issue:

```yaml
# Step 1: Generate report + template
- name: Generate weekly report
uses: QuantEcon/action-weekly-report@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
summary-template: 'true'

# Step 2: Create issue from report
- name: Create issue from report
id: create-issue
uses: peter-evans/create-issue-from-file@v4
with:
title: Weekly Activity Report
content-filepath: weekly-report.md
labels: report, automated

# Step 3: Post template as first comment
- name: Post comment summary template
if: hashFiles('comment-template.md') != ''
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ steps.create-issue.outputs.issue-number }}
body-path: comment-template.md
```

The template lands as the first comment on the new issue. A maintainer then edits that comment to curate the highlights.

### Manual

1. Run the action or CLI with `summary-template` enabled
2. Open `comment-template.md` — merged PRs are listed by repo
3. Reorganize into thematic sections (Lectures, Infrastructure, Libraries, etc.)
4. Add high-level context for each section
5. Remove PRs that don't need highlighting (e.g., automated dependency bumps)
6. Post as a comment on the activity report issue

## Action Outputs

The template content is also available as the `comment-template` output for use in downstream workflow steps:

```yaml
- name: Generate report
id: report
uses: QuantEcon/action-weekly-report@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
summary-template: 'true'

# Option 1: Pass to an action input (recommended — inherently safe)
- name: Post comment
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: 1
body: ${{ steps.report.outputs.comment-template }}

# Option 2: Use via environment variable (safe for run steps)
- name: Use template content
env:
TEMPLATE: ${{ steps.report.outputs.comment-template }}
run: echo "$TEMPLATE"
```

> **Security note:** Never interpolate `${{ steps.report.outputs.comment-template }}`
> directly in a `run:` block. The output contains PR titles, labels, and author names
> which could include shell metacharacters. Always pass it through an `env:` variable
> or an action `with:` input to avoid shell injection.

## Inputs

| Input | Description | Default |
|-------|-------------|---------|
| `summary-template` | Enable template generation (`true`/`false`) | `false` |
| `summary-template-file` | Output filename | `comment-template.md` |

| CLI Flag | Description |
|----------|-------------|
| `--summary-template` | Enable template generation |
| `--summary-template-file=FILE` | Output filename (default: `comment-template.md`) |
Loading
Loading