Files
the-nexus/.github/workflows/pr-duplicate-check.yml
Alexander Whitestone 73bbcd31f7
Some checks failed
CI / test (pull_request) Failing after 58s
CI / validate (pull_request) Failing after 29s
Review Approval Gate / verify-review (pull_request) Failing after 5s
feat: Add forge cleanup tools and documentation (#1128)
## Summary
Implements forge cleanup tools and documentation as requested in issue #1128.
Builds on the cleanup work done in issue #1127 and documented in #1128.

## Changes

### 1. Documentation
- **docs/forge-cleanup-analysis.md**: Detailed analysis of duplicate PRs and cleanup recommendations
- **docs/forge-cleanup-report.md**: Comprehensive cleanup report with metrics and next steps
- **scripts/README.md**: Documentation for the cleanup script

### 2. Tools
- **scripts/cleanup-duplicate-prs.sh**: Automated script for detecting and closing duplicate PRs
- **.github/workflows/pr-duplicate-check.yml**: GitHub Action for automated duplicate detection

## Features

### cleanup-duplicate-prs.sh
- **Issue-based grouping**: Groups PRs by issue number extracted from titles
- **Date-based selection**: Keeps the newest PR, closes older duplicates
- **Dry-run mode**: Shows what would be done without making changes
- **Stale PR detection**: Identifies PRs older than 30 days with no activity
- **Explanatory comments**: Adds comments when closing PRs to explain why

### GitHub Action Workflow
- **Weekly schedule**: Runs every Monday at 9 AM UTC
- **Manual trigger**: Can be run on-demand via workflow_dispatch
- **Automatic issue creation**: Creates issues when duplicates are found
- **Dry-run by default**: Safe to run without making changes

## Testing
- Script syntax validated
- Dry-run mode tested successfully
- No duplicate PRs currently found (cleanup already done)

## Acceptance Criteria
 Tools for detecting duplicate PRs
 Documentation of cleanup process
 Automated workflow for ongoing maintenance
 Safe dry-run mode for testing
 Explanatory comments when closing PRs

## Related Issues
- #1128: [RESOLVED] Forge Cleanup — PRs Closed, Milestones Deduplicated, Policy Issues Filed
- #1127: Evening triage pass (predecessor to #1128)

Issue: #1128
2026-04-13 21:44:53 -04:00

70 lines
2.0 KiB
YAML

name: Duplicate PR Detection
on:
schedule:
# Run weekly on Monday at 9 AM UTC
- cron: '0 9 * * 1'
workflow_dispatch: # Allow manual trigger
pull_request:
types: [opened, reopened]
jobs:
check-duplicates:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y jq curl
- name: Check for duplicate PRs
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
GITEA_URL: ${{ secrets.GITEA_URL || 'https://forge.alexanderwhitestone.com' }}
REPO: ${{ github.repository }}
run: |
chmod +x ./scripts/cleanup-duplicate-prs.sh
./scripts/cleanup-duplicate-prs.sh --dry-run
- name: Create issue if duplicates found
if: failure()
uses: actions/github-script@v7
with:
script: |
const title = 'Duplicate PRs Detected';
const body = `## Duplicate PRs Found
The duplicate PR detection workflow found potential duplicate PRs.
**Action Required:**
1. Review the duplicate PRs
2. Close older duplicates
3. Keep the newest PR for each issue
**Workflow Run:** ${context.runId}
**Repository:** ${context.repo.owner}/${context.repo.repo}
This issue was automatically created by the duplicate PR detection workflow.`;
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title,
body,
labels: ['maintenance', 'automated']
});
# Notify on manual trigger
notify:
needs: check-duplicates
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Send notification
run: |
echo "Duplicate PR check completed"
echo "Check the workflow run for details"