Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/update-pr-list.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Update Merged PR List

on:
pull_request:
types: [closed]

jobs:
update-readme:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Update README with merged PR
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_TITLE: ${{ github.event.pull_request.title }}
PR_URL: ${{ github.event.pull_request.html_url }}
PR_MERGED_AT: ${{ github.event.pull_request.merged_at }}
PR_LABELS: ${{ toJSON(github.event.pull_request.labels) }}
run: |
# Extract year from merged_at timestamp
YEAR=$(echo "$PR_MERGED_AT" | cut -d'-' -f1)

# Extract label names from JSON array
TAGS=$(echo "$PR_LABELS" | jq -r '[.[].name] | join(", ")')
if [ -z "$TAGS" ] || [ "$TAGS" = "null" ]; then
TAGS="-"
fi

# Escape special characters in title for sed
SAFE_TITLE=$(echo "$PR_TITLE" | sed 's/|/\\|/g')

# Create the new table row
NEW_ROW="| #${PR_NUMBER} | ${SAFE_TITLE} |"
NEW_ROW="${NEW_ROW} [Link](${PR_URL}) | ${YEAR} | ${TAGS} |"

# Find the line number of the table header
TABLE_HEADER_LINE=$(grep -n "| PR # | Title | Link | Year | Tags |" README.md | cut -d: -f1)

# Insert after the separator line (2 lines after header)
INSERT_LINE=$((TABLE_HEADER_LINE + 2))

# Insert the new row
sed -i "${INSERT_LINE}i ${NEW_ROW}" README.md

echo "Added PR #${PR_NUMBER} to README.md"
cat README.md

- name: Commit changes
run: |
git config --local user.email \
"github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add README.md
if ! git diff --staged --quiet; then
git commit -m \
"docs: add PR #${{ github.event.pull_request.number }} to list"
fi

- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Temporary files
*.tmp
*.log
*~
.DS_Store

# Editor files
.vscode/
.idea/
*.swp
*.swo

# Test files
/tmp/
test_*.sh

# OS files
Thumbs.db
78 changes: 77 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,77 @@
# Opensource-Merged-PR-s-
# Opensource Merged PRs Tracker

This repository automatically tracks all merged Pull Requests with detailed information.

## 🚀 Quick Start

1. Fork or clone this repository
2. Ensure GitHub Actions has write permissions:
- Go to Settings → Actions → General
- Select "Read and write permissions"
3. (Optional) Run the backfill script to add your historical merged PRs:
```bash
./scripts/backfill-historical-prs.sh
```
4. Start merging PRs - they'll be automatically tracked!

## 📊 Merged Pull Requests

<!-- PR_LIST_START -->

| PR # | Title | Link | Year | Tags |
|------|-------|------|------|------|
| #2392 | Prevent invalid user ID (ServiceNowDevProgram/code-snippets) | [Link](https://github.com/ServiceNowDevProgram/code-snippets/pull/2392) | 2025 | - |
| #2381 | Correct Readme files added according to the scripts (ServiceNowDevProgram/code-snippets) | [Link](https://github.com/ServiceNowDevProgram/code-snippets/pull/2381) | 2025 | - |
| #2376 | Script to update all email domains (ServiceNowDevProgram/code-snippets) | [Link](https://github.com/ServiceNowDevProgram/code-snippets/pull/2376) | 2025 | - |
| #1 | Event Space booking Application (SumithThota/Servicenow) | [Link](https://github.com/SumithThota/Servicenow/pull/1) | 2025 | - |
| #2064 | Add CartJS script to submit catalog items (ServiceNowDevProgram/code-snippets) | [Link](https://github.com/ServiceNowDevProgram/code-snippets/pull/2064) | 2025 | - |
| #2052 | Bugfix added comprehensive email regex pattern (ServiceNowDevProgram/code-snippets) | [Link](https://github.com/ServiceNowDevProgram/code-snippets/pull/2052) | 2025 | - |
| #843 | Successfully enhanced box shadow of DIV's in both Scholarship pages (aditya-bhaumik/Pathsphere) | [Link](https://github.com/aditya-bhaumik/Pathsphere/pull/843) | 2024 | gssoc-ext, level 1, hacktoberfest-accepted |
| #550 | Update auto-assign-label-pr.yml (swaraj-das/Collect-your-GamingTools) | [Link](https://github.com/swaraj-das/Collect-your-GamingTools/pull/550) | 2024 | - |
| #549 | Successfully youtube icon got responsive with hover (swaraj-das/Collect-your-GamingTools) | [Link](https://github.com/swaraj-das/Collect-your-GamingTools/pull/549) | 2024 | gssoc-ext, level1, hacktoberfest-accepted |
| #1262 | Hover effect successfully added to Login & Register Buttons (anuragverma108/WildGuard) | [Link](https://github.com/anuragverma108/WildGuard/pull/1262) | 2024 | hacktoberfest-accepted, hacktoberfest |
| #445 | Update add-your-certificate.md (GSSoC24/Postman-Challenge) | [Link](https://github.com/GSSoC24/Postman-Challenge/pull/445) | 2024 | postman, gssoc |
| #1323 | Margin is added to each card successfully (khushi-joshi-05/Food-ordering-website) | [Link](https://github.com/khushi-joshi-05/Food-ordering-website/pull/1323) | 2024 | gssoc |
| #1548 | Added Centroid Of A Triangle Calculator (Rakesh9100/CalcDiverse) | [Link](https://github.com/Rakesh9100/CalcDiverse/pull/1548) | 2024 | Completed 🥳, gssoc, level3 |
| #934 | fix: Issue #861 Removed improper Flickering of elements (apu52/Travel_Website) | [Link](https://github.com/apu52/Travel_Website/pull/934) | 2024 | bug, level1, gssoc |
| #1001 | Navbar Position is fixed Properly (Suchitra-Sahoo/AgriLearnNetwork) | [Link](https://github.com/Suchitra-Sahoo/AgriLearnNetwork/pull/1001) | 2024 | gssoc, level1 |
| #1440 | Added Trisection Point Calculator (Rakesh9100/CalcDiverse) | [Link](https://github.com/Rakesh9100/CalcDiverse/pull/1440) | 2024 | Completed 🥳, gssoc, level3 |
| #972 | Sets proper fonts size to FAQs (Suchitra-Sahoo/AgriLearnNetwork) | [Link](https://github.com/Suchitra-Sahoo/AgriLearnNetwork/pull/972) | 2024 | gssoc, level1 |
| #923 | Hover to quicklinks is added to all pages & FAQ is added (Suchitra-Sahoo/AgriLearnNetwork) | [Link](https://github.com/Suchitra-Sahoo/AgriLearnNetwork/pull/923) | 2024 | gssoc, level2 |
| #898 | Updated welcome div by enhancing it & added glow effect (Suchitra-Sahoo/AgriLearnNetwork) | [Link](https://github.com/Suchitra-Sahoo/AgriLearnNetwork/pull/898) | 2024 | gssoc, level1 |

<!-- PR_LIST_END -->

## ✨ Features

- 🔄 **Automatic Updates**: README is updated instantly when PRs are merged
- 📝 **Rich Information**: Captures PR number, title, link, year, and tags
- 🏷️ **Tag Support**: Automatically extracts and displays PR labels
- 🔗 **Direct Links**: Quick access to merged PRs
- 📅 **Year Tracking**: Organizes PRs by merge year
- 🤖 **Zero Maintenance**: Fully automated with GitHub Actions

## 🤖 How It Works

This repository uses GitHub Actions to automatically update the table above whenever a PR is merged.

**Workflow Process:**
```
PR Merged → GitHub Actions Triggered → Extract PR Details → Update README Table → Auto Commit & Push
```

The workflow:
1. Detects when a PR is merged
2. Extracts PR details (number, title, labels, merge date)
3. Updates this README with the new entry
4. Commits the changes automatically

📖 For detailed setup and customization instructions, see [SETUP.md](SETUP.md)

## 📝 Table Columns

- **PR #**: The pull request number
- **Title**: The title of the merged PR
- **Link**: Direct link to the PR
- **Year**: Year when the PR was merged
- **Tags**: Labels/tags associated with the PR
208 changes: 208 additions & 0 deletions SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
# Setup and Usage Guide

## Overview

This repository automatically tracks all merged Pull Requests using GitHub Actions. Every time a PR is merged, the workflow automatically updates the README.md file with the PR details.

## How the Automation Works

### Trigger
The automation is triggered when a Pull Request is closed. It only runs when the PR is actually merged (not just closed without merging).

### Workflow Steps

1. **Detection**: GitHub Actions detects when a PR is merged
2. **Checkout**: The workflow checks out the repository code
3. **Data Extraction**: Extracts the following information:
- PR Number
- PR Title
- PR URL
- Merge Date (Year)
- Labels/Tags
4. **Update README**: Inserts a new row in the README table with the PR information
5. **Commit & Push**: Automatically commits and pushes the changes back to the repository

### Data Processing

- **Year Extraction**: Parses the merge timestamp to get the year
- **Label Processing**: Converts label array to comma-separated string
- **Special Character Handling**: Escapes special characters (like `|`) in PR titles
- **Table Formatting**: Maintains proper markdown table format

## File Structure

```
.
├── README.md # Main file with PR tracking table
├── .github/
│ └── workflows/
│ └── update-pr-list.yml # GitHub Actions workflow
└── SETUP.md # This file
```

## Configuration

### Required Permissions

The workflow needs the following permissions (already configured):
- `contents: write` - To commit and push changes to README.md
- `pull-requests: read` - To read PR details

### Repository Settings

1. Go to repository **Settings** → **Actions** → **General**
2. Under **Workflow permissions**, ensure:
- "Read and write permissions" is selected
- "Allow GitHub Actions to create and approve pull requests" is checked (optional)

## Customization

### Modifying the Table Format

To change the table columns or format, edit the workflow file:

```yaml
# In .github/workflows/update-pr-list.yml
# Modify the NEW_ROW variable to change table format
NEW_ROW="| #${PR_NUMBER} | ${SAFE_TITLE} | [Link](${PR_URL}) | ${YEAR} | ${TAGS} |"
```

### Adding More PR Information

You can add more fields from the GitHub event payload. Available fields include:
- `github.event.pull_request.user.login` - PR author
- `github.event.pull_request.merged_by.login` - Who merged the PR
- `github.event.pull_request.base.ref` - Base branch
- `github.event.pull_request.head.ref` - Head branch

Example to add author:
```yaml
env:
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
```

### Changing the Sort Order

Currently, new PRs are added at the top of the list. To add them at the bottom:

Change:
```bash
sed -i "/<!-- PR_LIST_START -->/a ${NEW_ROW}" README.md
```

To:
```bash
sed -i "/<!-- PR_LIST_END -->/i ${NEW_ROW}" README.md
```

## Testing

### Local Testing

You can test the workflow logic locally using the test script:

```bash
# Set environment variables
export PR_NUMBER=123
export PR_TITLE="Test PR"
export PR_URL="https://github.com/owner/repo/pull/123"
export PR_MERGED_AT="2025-11-17T07:00:00Z"
export PR_LABELS='[{"name": "bug"}, {"name": "critical"}]'

# Run the workflow commands
YEAR=$(echo "$PR_MERGED_AT" | cut -d'-' -f1)
TAGS=$(echo "$PR_LABELS" | jq -r '[.[].name] | join(", ")')
# ... etc
```

### Workflow Testing

1. Create a test branch
2. Make some changes and open a PR
3. Merge the PR
4. Check if the README.md is updated automatically

### Backfilling Historical PRs

To populate the table with your previously merged PRs from other repositories:

#### Option 1: Using the Backfill Script (Requires GitHub CLI)

```bash
# Install GitHub CLI if not already installed
# Visit: https://cli.github.com/

# Authenticate with GitHub
gh auth login

# Run the backfill script
./scripts/backfill-historical-prs.sh
```

The script will:
1. Search for all your merged PRs across GitHub
2. Extract PR details (number, title, URL, year, labels, repository)
3. Add them to the README table
4. Create a backup (README.md.backup) before making changes

#### Option 2: Manual Addition

You can manually add historical PRs by editing README.md:

```markdown
<!-- PR_LIST_START -->
| #123 | My PR Title (owner/repo) | [Link](url) | 2024 | bug, feature |
<!-- PR_LIST_END -->
```

**Important**: Always add new entries between the `<!-- PR_LIST_START -->` and `<!-- PR_LIST_END -->` markers.

## Troubleshooting

### Workflow Not Running

1. Check if the workflow file is in the correct location: `.github/workflows/update-pr-list.yml`
2. Verify repository permissions (Settings → Actions → General)
3. Check the Actions tab for any errors

### README Not Updated

1. Check the workflow logs in the Actions tab
2. Verify that the PR was actually merged (not just closed)
3. Ensure the markers `<!-- PR_LIST_START -->` and `<!-- PR_LIST_END -->` exist in README.md

### Permission Errors

If you see permission errors:
1. Go to Settings → Actions → General
2. Enable "Read and write permissions"
3. Re-run the workflow

## Best Practices

1. **Don't manually edit** the PR list section between the markers
2. **Keep the markers** (`<!-- PR_LIST_START -->` and `<!-- PR_LIST_END -->`) intact
3. **Use meaningful PR titles** as they will appear in the table
4. **Add relevant labels** to PRs for better categorization
5. **Review the automated commit** after merging to ensure correct formatting

## Example Workflow

Here's what happens when you merge a PR:

1. You merge PR #5 titled "Add new feature" with labels "enhancement" and "feature"
2. GitHub Actions workflow is triggered
3. Workflow extracts: PR #5, title, URL, year 2025, tags "enhancement, feature"
4. A new row is added to the README table:
```
| #5 | Add new feature | [Link](url) | 2025 | enhancement, feature |
```
5. Changes are committed and pushed automatically
6. README is updated instantly

## Support

For issues or questions:
1. Check the workflow logs in the Actions tab
2. Review this documentation
3. Check GitHub Actions documentation for more details on workflows
Loading