Created
July 9, 2025 02:08
-
-
Save Mossman1215/c770347a2d3d040f2b4896369d677280 to your computer and use it in GitHub Desktop.
12 month review github
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash -e | |
| # Requirements: | |
| # - gh CLI: https://cli.github.com/ | |
| # - jq: https://stedolan.github.io/jq/ | |
| # - git (for optional local repo work, not required for this script) | |
| # - Authenticated with GitHub CLI (gh auth login) | |
| # - Set your GitHub username below | |
| GITHUB_USER="Mossman1215" | |
| ORG="GeoNet" | |
| SINCE_DATE=$(date -u -d "12 months ago" +"%Y-%m-%dT%H:%M:%SZ") | |
| # Fetch all GeoNet repositories (max 100, paginate if needed) | |
| REPOS=$(gh repo list "$ORG" --limit 100 --json name -q '.[].name') | |
| for REPO in $REPOS; do | |
| echo "Checking PRs in $ORG/$REPO..." >> PR-MSG.txt | |
| # Get PRs authored by the user, merged or closed in last 12 months | |
| PRS=$(gh pr list -R "$ORG/$REPO" \ | |
| --author "$GITHUB_USER" \ | |
| --state "merged" \ | |
| --json "number,updatedAt,mergedAt" \ | |
| --jq ".[] | select((.mergedAt != null and .mergedAt > \"$SINCE_DATE\") or (.updatedAt > \"$SINCE_DATE\")) | .number") | |
| for PR_NUMBER in $PRS; do | |
| echo " PR #$PR_NUMBER:" >> PR-MSG.txt | |
| # Fetch commit messages for this PR using the GitHub REST API | |
| COMMITS=$(gh api \ | |
| -H "Accept: application/vnd.github+json" \ | |
| "/repos/$ORG/$REPO/pulls/$PR_NUMBER/commits" \ | |
| --jq '.[].commit.message') | |
| while IFS= read -r MSG; do | |
| echo "$MSG" >> PR-MSG.txt | |
| done <<< "$COMMITS" | |
| done | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment