Skip to content

Commit 2f0c38b

Browse files
authored
Merge pull request #1 from SumithThota/copilot/create-repo-and-readme
Add automated merged PR tracking with GitHub Actions and historical PRs backfill
2 parents 8f208f5 + 2ea66cc commit 2f0c38b

File tree

5 files changed

+470
-1
lines changed

5 files changed

+470
-1
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Update Merged PR List
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
jobs:
8+
update-readme:
9+
if: github.event.pull_request.merged == true
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
pull-requests: read
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Update README with merged PR
22+
env:
23+
PR_NUMBER: ${{ github.event.pull_request.number }}
24+
PR_TITLE: ${{ github.event.pull_request.title }}
25+
PR_URL: ${{ github.event.pull_request.html_url }}
26+
PR_MERGED_AT: ${{ github.event.pull_request.merged_at }}
27+
PR_LABELS: ${{ toJSON(github.event.pull_request.labels) }}
28+
run: |
29+
# Extract year from merged_at timestamp
30+
YEAR=$(echo "$PR_MERGED_AT" | cut -d'-' -f1)
31+
32+
# Extract label names from JSON array
33+
TAGS=$(echo "$PR_LABELS" | jq -r '[.[].name] | join(", ")')
34+
if [ -z "$TAGS" ] || [ "$TAGS" = "null" ]; then
35+
TAGS="-"
36+
fi
37+
38+
# Escape special characters in title for sed
39+
SAFE_TITLE=$(echo "$PR_TITLE" | sed 's/|/\\|/g')
40+
41+
# Create the new table row
42+
NEW_ROW="| #${PR_NUMBER} | ${SAFE_TITLE} |"
43+
NEW_ROW="${NEW_ROW} [Link](${PR_URL}) | ${YEAR} | ${TAGS} |"
44+
45+
# Find the line number of the table header
46+
TABLE_HEADER_LINE=$(grep -n "| PR # | Title | Link | Year | Tags |" README.md | cut -d: -f1)
47+
48+
# Insert after the separator line (2 lines after header)
49+
INSERT_LINE=$((TABLE_HEADER_LINE + 2))
50+
51+
# Insert the new row
52+
sed -i "${INSERT_LINE}i ${NEW_ROW}" README.md
53+
54+
echo "Added PR #${PR_NUMBER} to README.md"
55+
cat README.md
56+
57+
- name: Commit changes
58+
run: |
59+
git config --local user.email \
60+
"github-actions[bot]@users.noreply.github.com"
61+
git config --local user.name "github-actions[bot]"
62+
git add README.md
63+
if ! git diff --staged --quiet; then
64+
git commit -m \
65+
"docs: add PR #${{ github.event.pull_request.number }} to list"
66+
fi
67+
68+
- name: Push changes
69+
uses: ad-m/github-push-action@master
70+
with:
71+
github_token: ${{ secrets.GITHUB_TOKEN }}
72+
branch: ${{ github.ref }}

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Temporary files
2+
*.tmp
3+
*.log
4+
*~
5+
.DS_Store
6+
7+
# Editor files
8+
.vscode/
9+
.idea/
10+
*.swp
11+
*.swo
12+
13+
# Test files
14+
/tmp/
15+
test_*.sh
16+
17+
# OS files
18+
Thumbs.db

README.md

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,77 @@
1-
# Opensource-Merged-PR-s-
1+
# Opensource Merged PRs Tracker
2+
3+
This repository automatically tracks all merged Pull Requests with detailed information.
4+
5+
## 🚀 Quick Start
6+
7+
1. Fork or clone this repository
8+
2. Ensure GitHub Actions has write permissions:
9+
- Go to Settings → Actions → General
10+
- Select "Read and write permissions"
11+
3. (Optional) Run the backfill script to add your historical merged PRs:
12+
```bash
13+
./scripts/backfill-historical-prs.sh
14+
```
15+
4. Start merging PRs - they'll be automatically tracked!
16+
17+
## 📊 Merged Pull Requests
18+
19+
<!-- PR_LIST_START -->
20+
21+
| PR # | Title | Link | Year | Tags |
22+
|------|-------|------|------|------|
23+
| #2392 | Prevent invalid user ID (ServiceNowDevProgram/code-snippets) | [Link](https://github.com/ServiceNowDevProgram/code-snippets/pull/2392) | 2025 | - |
24+
| #2381 | Correct Readme files added according to the scripts (ServiceNowDevProgram/code-snippets) | [Link](https://github.com/ServiceNowDevProgram/code-snippets/pull/2381) | 2025 | - |
25+
| #2376 | Script to update all email domains (ServiceNowDevProgram/code-snippets) | [Link](https://github.com/ServiceNowDevProgram/code-snippets/pull/2376) | 2025 | - |
26+
| #1 | Event Space booking Application (SumithThota/Servicenow) | [Link](https://github.com/SumithThota/Servicenow/pull/1) | 2025 | - |
27+
| #2064 | Add CartJS script to submit catalog items (ServiceNowDevProgram/code-snippets) | [Link](https://github.com/ServiceNowDevProgram/code-snippets/pull/2064) | 2025 | - |
28+
| #2052 | Bugfix added comprehensive email regex pattern (ServiceNowDevProgram/code-snippets) | [Link](https://github.com/ServiceNowDevProgram/code-snippets/pull/2052) | 2025 | - |
29+
| #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 |
30+
| #550 | Update auto-assign-label-pr.yml (swaraj-das/Collect-your-GamingTools) | [Link](https://github.com/swaraj-das/Collect-your-GamingTools/pull/550) | 2024 | - |
31+
| #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 |
32+
| #1262 | Hover effect successfully added to Login & Register Buttons (anuragverma108/WildGuard) | [Link](https://github.com/anuragverma108/WildGuard/pull/1262) | 2024 | hacktoberfest-accepted, hacktoberfest |
33+
| #445 | Update add-your-certificate.md (GSSoC24/Postman-Challenge) | [Link](https://github.com/GSSoC24/Postman-Challenge/pull/445) | 2024 | postman, gssoc |
34+
| #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 |
35+
| #1548 | Added Centroid Of A Triangle Calculator (Rakesh9100/CalcDiverse) | [Link](https://github.com/Rakesh9100/CalcDiverse/pull/1548) | 2024 | Completed 🥳, gssoc, level3 |
36+
| #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 |
37+
| #1001 | Navbar Position is fixed Properly (Suchitra-Sahoo/AgriLearnNetwork) | [Link](https://github.com/Suchitra-Sahoo/AgriLearnNetwork/pull/1001) | 2024 | gssoc, level1 |
38+
| #1440 | Added Trisection Point Calculator (Rakesh9100/CalcDiverse) | [Link](https://github.com/Rakesh9100/CalcDiverse/pull/1440) | 2024 | Completed 🥳, gssoc, level3 |
39+
| #972 | Sets proper fonts size to FAQs (Suchitra-Sahoo/AgriLearnNetwork) | [Link](https://github.com/Suchitra-Sahoo/AgriLearnNetwork/pull/972) | 2024 | gssoc, level1 |
40+
| #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 |
41+
| #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 |
42+
43+
<!-- PR_LIST_END -->
44+
45+
## ✨ Features
46+
47+
- 🔄 **Automatic Updates**: README is updated instantly when PRs are merged
48+
- 📝 **Rich Information**: Captures PR number, title, link, year, and tags
49+
- 🏷️ **Tag Support**: Automatically extracts and displays PR labels
50+
- 🔗 **Direct Links**: Quick access to merged PRs
51+
- 📅 **Year Tracking**: Organizes PRs by merge year
52+
- 🤖 **Zero Maintenance**: Fully automated with GitHub Actions
53+
54+
## 🤖 How It Works
55+
56+
This repository uses GitHub Actions to automatically update the table above whenever a PR is merged.
57+
58+
**Workflow Process:**
59+
```
60+
PR Merged → GitHub Actions Triggered → Extract PR Details → Update README Table → Auto Commit & Push
61+
```
62+
63+
The workflow:
64+
1. Detects when a PR is merged
65+
2. Extracts PR details (number, title, labels, merge date)
66+
3. Updates this README with the new entry
67+
4. Commits the changes automatically
68+
69+
📖 For detailed setup and customization instructions, see [SETUP.md](SETUP.md)
70+
71+
## 📝 Table Columns
72+
73+
- **PR #**: The pull request number
74+
- **Title**: The title of the merged PR
75+
- **Link**: Direct link to the PR
76+
- **Year**: Year when the PR was merged
77+
- **Tags**: Labels/tags associated with the PR

SETUP.md

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
# Setup and Usage Guide
2+
3+
## Overview
4+
5+
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.
6+
7+
## How the Automation Works
8+
9+
### Trigger
10+
The automation is triggered when a Pull Request is closed. It only runs when the PR is actually merged (not just closed without merging).
11+
12+
### Workflow Steps
13+
14+
1. **Detection**: GitHub Actions detects when a PR is merged
15+
2. **Checkout**: The workflow checks out the repository code
16+
3. **Data Extraction**: Extracts the following information:
17+
- PR Number
18+
- PR Title
19+
- PR URL
20+
- Merge Date (Year)
21+
- Labels/Tags
22+
4. **Update README**: Inserts a new row in the README table with the PR information
23+
5. **Commit & Push**: Automatically commits and pushes the changes back to the repository
24+
25+
### Data Processing
26+
27+
- **Year Extraction**: Parses the merge timestamp to get the year
28+
- **Label Processing**: Converts label array to comma-separated string
29+
- **Special Character Handling**: Escapes special characters (like `|`) in PR titles
30+
- **Table Formatting**: Maintains proper markdown table format
31+
32+
## File Structure
33+
34+
```
35+
.
36+
├── README.md # Main file with PR tracking table
37+
├── .github/
38+
│ └── workflows/
39+
│ └── update-pr-list.yml # GitHub Actions workflow
40+
└── SETUP.md # This file
41+
```
42+
43+
## Configuration
44+
45+
### Required Permissions
46+
47+
The workflow needs the following permissions (already configured):
48+
- `contents: write` - To commit and push changes to README.md
49+
- `pull-requests: read` - To read PR details
50+
51+
### Repository Settings
52+
53+
1. Go to repository **Settings****Actions****General**
54+
2. Under **Workflow permissions**, ensure:
55+
- "Read and write permissions" is selected
56+
- "Allow GitHub Actions to create and approve pull requests" is checked (optional)
57+
58+
## Customization
59+
60+
### Modifying the Table Format
61+
62+
To change the table columns or format, edit the workflow file:
63+
64+
```yaml
65+
# In .github/workflows/update-pr-list.yml
66+
# Modify the NEW_ROW variable to change table format
67+
NEW_ROW="| #${PR_NUMBER} | ${SAFE_TITLE} | [Link](${PR_URL}) | ${YEAR} | ${TAGS} |"
68+
```
69+
70+
### Adding More PR Information
71+
72+
You can add more fields from the GitHub event payload. Available fields include:
73+
- `github.event.pull_request.user.login` - PR author
74+
- `github.event.pull_request.merged_by.login` - Who merged the PR
75+
- `github.event.pull_request.base.ref` - Base branch
76+
- `github.event.pull_request.head.ref` - Head branch
77+
78+
Example to add author:
79+
```yaml
80+
env:
81+
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
82+
```
83+
84+
### Changing the Sort Order
85+
86+
Currently, new PRs are added at the top of the list. To add them at the bottom:
87+
88+
Change:
89+
```bash
90+
sed -i "/<!-- PR_LIST_START -->/a ${NEW_ROW}" README.md
91+
```
92+
93+
To:
94+
```bash
95+
sed -i "/<!-- PR_LIST_END -->/i ${NEW_ROW}" README.md
96+
```
97+
98+
## Testing
99+
100+
### Local Testing
101+
102+
You can test the workflow logic locally using the test script:
103+
104+
```bash
105+
# Set environment variables
106+
export PR_NUMBER=123
107+
export PR_TITLE="Test PR"
108+
export PR_URL="https://github.com/owner/repo/pull/123"
109+
export PR_MERGED_AT="2025-11-17T07:00:00Z"
110+
export PR_LABELS='[{"name": "bug"}, {"name": "critical"}]'
111+
112+
# Run the workflow commands
113+
YEAR=$(echo "$PR_MERGED_AT" | cut -d'-' -f1)
114+
TAGS=$(echo "$PR_LABELS" | jq -r '[.[].name] | join(", ")')
115+
# ... etc
116+
```
117+
118+
### Workflow Testing
119+
120+
1. Create a test branch
121+
2. Make some changes and open a PR
122+
3. Merge the PR
123+
4. Check if the README.md is updated automatically
124+
125+
### Backfilling Historical PRs
126+
127+
To populate the table with your previously merged PRs from other repositories:
128+
129+
#### Option 1: Using the Backfill Script (Requires GitHub CLI)
130+
131+
```bash
132+
# Install GitHub CLI if not already installed
133+
# Visit: https://cli.github.com/
134+
135+
# Authenticate with GitHub
136+
gh auth login
137+
138+
# Run the backfill script
139+
./scripts/backfill-historical-prs.sh
140+
```
141+
142+
The script will:
143+
1. Search for all your merged PRs across GitHub
144+
2. Extract PR details (number, title, URL, year, labels, repository)
145+
3. Add them to the README table
146+
4. Create a backup (README.md.backup) before making changes
147+
148+
#### Option 2: Manual Addition
149+
150+
You can manually add historical PRs by editing README.md:
151+
152+
```markdown
153+
<!-- PR_LIST_START -->
154+
| #123 | My PR Title (owner/repo) | [Link](url) | 2024 | bug, feature |
155+
<!-- PR_LIST_END -->
156+
```
157+
158+
**Important**: Always add new entries between the `<!-- PR_LIST_START -->` and `<!-- PR_LIST_END -->` markers.
159+
160+
## Troubleshooting
161+
162+
### Workflow Not Running
163+
164+
1. Check if the workflow file is in the correct location: `.github/workflows/update-pr-list.yml`
165+
2. Verify repository permissions (Settings → Actions → General)
166+
3. Check the Actions tab for any errors
167+
168+
### README Not Updated
169+
170+
1. Check the workflow logs in the Actions tab
171+
2. Verify that the PR was actually merged (not just closed)
172+
3. Ensure the markers `<!-- PR_LIST_START -->` and `<!-- PR_LIST_END -->` exist in README.md
173+
174+
### Permission Errors
175+
176+
If you see permission errors:
177+
1. Go to Settings → Actions → General
178+
2. Enable "Read and write permissions"
179+
3. Re-run the workflow
180+
181+
## Best Practices
182+
183+
1. **Don't manually edit** the PR list section between the markers
184+
2. **Keep the markers** (`<!-- PR_LIST_START -->` and `<!-- PR_LIST_END -->`) intact
185+
3. **Use meaningful PR titles** as they will appear in the table
186+
4. **Add relevant labels** to PRs for better categorization
187+
5. **Review the automated commit** after merging to ensure correct formatting
188+
189+
## Example Workflow
190+
191+
Here's what happens when you merge a PR:
192+
193+
1. You merge PR #5 titled "Add new feature" with labels "enhancement" and "feature"
194+
2. GitHub Actions workflow is triggered
195+
3. Workflow extracts: PR #5, title, URL, year 2025, tags "enhancement, feature"
196+
4. A new row is added to the README table:
197+
```
198+
| #5 | Add new feature | [Link](url) | 2025 | enhancement, feature |
199+
```
200+
5. Changes are committed and pushed automatically
201+
6. README is updated instantly
202+
203+
## Support
204+
205+
For issues or questions:
206+
1. Check the workflow logs in the Actions tab
207+
2. Review this documentation
208+
3. Check GitHub Actions documentation for more details on workflows

0 commit comments

Comments
 (0)