diff --git a/.github/workflows/update-pr-list.yml b/.github/workflows/update-pr-list.yml new file mode 100644 index 0000000..c6eed7b --- /dev/null +++ b/.github/workflows/update-pr-list.yml @@ -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 }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..230c816 --- /dev/null +++ b/.gitignore @@ -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 diff --git a/README.md b/README.md index 8bebd41..a38fabc 100644 --- a/README.md +++ b/README.md @@ -1 +1,77 @@ -# Opensource-Merged-PR-s- \ No newline at end of file +# 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 # | 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 | + + + +## ✨ 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 \ No newline at end of file diff --git a/SETUP.md b/SETUP.md new file mode 100644 index 0000000..6217e05 --- /dev/null +++ b/SETUP.md @@ -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 "//a ${NEW_ROW}" README.md +``` + +To: +```bash +sed -i "//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 + +| #123 | My PR Title (owner/repo) | [Link](url) | 2024 | bug, feature | + +``` + +**Important**: Always add new entries between the `` and `` 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 `` and `` 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** (`` and ``) 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 diff --git a/scripts/backfill-historical-prs.sh b/scripts/backfill-historical-prs.sh new file mode 100755 index 0000000..23a3c89 --- /dev/null +++ b/scripts/backfill-historical-prs.sh @@ -0,0 +1,95 @@ +#!/bin/bash + +# Backfill Script for Historical Merged PRs +# This script fetches all previously merged PRs by the user and adds them to README.md + +echo "🔍 Fetching historical merged PRs..." + +# GitHub username (change this if needed) +GITHUB_USER="SumithThota" + +# Create a temporary file to store PR data +TEMP_FILE="/tmp/historical_prs.txt" +> "$TEMP_FILE" + +# Fetch merged PRs using GitHub CLI (requires 'gh' to be installed) +if ! command -v gh &> /dev/null; then + echo "❌ Error: GitHub CLI (gh) is not installed." + echo "Please install it from: https://cli.github.com/" + exit 1 +fi + +echo "📥 Fetching PRs from GitHub..." + +# Search for all merged PRs by the user +gh search prs --author "$GITHUB_USER" --merged --json number,title,url,mergedAt,repository,labels --limit 1000 | jq -r '.[] | + @json' | while read -r pr_json; do + + # Parse PR data + PR_NUMBER=$(echo "$pr_json" | jq -r '.number') + PR_TITLE=$(echo "$pr_json" | jq -r '.title') + PR_URL=$(echo "$pr_json" | jq -r '.url') + PR_MERGED_AT=$(echo "$pr_json" | jq -r '.mergedAt') + REPO_NAME=$(echo "$pr_json" | jq -r '.repository.nameWithOwner') + + # Extract year + YEAR=$(echo "$PR_MERGED_AT" | cut -d'-' -f1) + + # Extract labels + LABELS=$(echo "$pr_json" | jq -r '[.labels[].name] | join(", ")') + if [ -z "$LABELS" ] || [ "$LABELS" = "null" ]; then + LABELS="-" + fi + + # Escape special characters in title + SAFE_TITLE=$(echo "$PR_TITLE" | sed 's/|/\\|/g') + + # Create table row with repo name + echo "| #${PR_NUMBER} | ${SAFE_TITLE} (${REPO_NAME}) | [Link](${PR_URL}) | ${YEAR} | ${LABELS} |" >> "$TEMP_FILE" + + echo "✅ Added: PR #${PR_NUMBER} from ${REPO_NAME}" +done + +# Count how many PRs were found +PR_COUNT=$(wc -l < "$TEMP_FILE") + +if [ "$PR_COUNT" -eq 0 ]; then + echo "⚠️ No historical PRs found." + exit 0 +fi + +echo "" +echo "📊 Found $PR_COUNT merged PRs!" +echo "" + +# Backup current README +echo "💾 Backing up current README.md..." +cp README.md README.md.backup + +# Insert all historical PRs into README +echo "📝 Updating README.md..." + +# 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)) + +# Read the temp file in reverse order (newest first) and insert after separator +LINE_NUM=$INSERT_LINE +while IFS= read -r line; do + sed -i "${LINE_NUM}i $line" README.md + echo "✅ Inserted at line $LINE_NUM" +done < <(tac "$TEMP_FILE") + +echo "✅ README.md has been updated with $PR_COUNT historical PRs!" +echo "" +echo "📋 Next steps:" +echo "1. Review the changes: git diff README.md" +echo "2. If satisfied, commit: git add README.md && git commit -m 'docs: add historical merged PRs'" +echo "3. If not satisfied, restore backup: mv README.md.backup README.md" +echo "" +echo "💡 Backup saved as: README.md.backup" + +# Clean up +rm "$TEMP_FILE"