Skip to content

List Open PRs

List Open PRs #308

Workflow file for this run

name: List Open PRs
on:
schedule:
- cron: '0 0 * * *' # Runs daily at midnight
workflow_dispatch: # Allows manual triggering
jobs:
list-open-prs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: List open PRs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ORG_NAME: nanoframework
run: |
# read all the repos, each page being 30 items
page=1
repos=""
while :; do
response=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/orgs/$ORG_NAME/repos?page=$page&per_page=100")
repo_names=$(echo "$response" | jq -r '.[].name')
if [ -z "$repo_names" ]; then
break
fi
repos="$repos $repo_names"
page=$((page + 1))
done
recent_prs=""
for repo in $repos; do
# Fetch raw JSON for PRs
prs_json=$(curl -s -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/$ORG_NAME/$repo/pulls?state=open)
# Check if there are any open PRs in the repository
if [ "$(echo "$prs_json" | jq -r '. | length')" -eq 0 ]; then
# Skip the repo if there are no open PRs
continue
else
echo -e "\nRepository: $repo"
echo "$prs_json" | jq -r '.[] | "\(.html_url) - \(.title) - Opened on: \(.created_at | split("T")[0])"'
fi
# Filter PRs opened in the last 3 days
recent_prs_repo=$(echo "$prs_json" | jq -r --arg date "$(date -d '3 days ago' +%Y-%m-%dT%H:%M:%SZ)" '.[] | select(.created_at >= $date) | "\(.html_url) - \(.title) - Opened on: \(.created_at | split("T")[0])"')
recent_prs="$recent_prs\n$recent_prs_repo"
# Filter PRs opened more than 1 month ago
old_prs_repo=$(echo "$prs_json" | jq -r --arg date "$(date -d '1 month ago' +%Y-%m-%dT%H:%M:%SZ)" '.[] | select(.created_at < $date) | "\(.html_url) - \(.title) - Opened on: \(.created_at | split("T")[0])"')
old_prs="$old_prs\n$old_prs_repo"
done
# Remove empty lines from the final recent_prs
recent_prs=$(echo -e "$recent_prs" | grep -v '^\s*$')
# Remove empty lines from the final old_prs
old_prs=$(echo -e "$old_prs" | grep -v '^\s*$')
echo -e "\nRecap of PRs opened in the last 3 days:"
if [ -z "$recent_prs" ]; then
echo "None"
else
echo -e "$recent_prs"
fi
echo -e "\nRecap of PRs opened more than 1 month ago:"
if [ -z "$old_prs" ]; then
echo "None"
else
echo -e "$old_prs"
fi