Label recent pull requests #8
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
| name: Label recent pull requests | |
| on: | |
| schedule: | |
| - cron: "0 2 * * *" # 02:00 UTC daily | |
| workflow_dispatch: # allow manual runs | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| issues: write | |
| jobs: | |
| label-prs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Auto-label PRs | |
| env: | |
| REPO: ${{ github.repository }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| REPO=MariaDB/server | |
| set -euo pipefail | |
| # List first 200 PRs lacking classification labels as JSON | |
| gh pr list \ | |
| --repo "$REPO" \ | |
| --search 'is:pr AND -label:"External Contribution" AND -label:"MariaDB Foundation" AND -label:"MariaDB Corporation" AND -label:"Codership" AND created:>2025-11' \ | |
| --limit 200 \ | |
| -s all \ | |
| --json number,author \ | |
| --jq '.[]' | | |
| while read -r pr; do | |
| pr_number=$(echo "$pr" | jq -r '.number') | |
| author=$(echo "$pr" | jq -r '.author.login') | |
| echo "Evaluating PR #$pr_number by $author" | |
| echo "Check if author is in the developers team" | |
| if gh api \ | |
| -H "Accept: application/vnd.github+json" \ | |
| "/orgs/MariaDB/teams/developers/members/$author" \ | |
| 2>&1; then | |
| echo "Author is in developers team" | |
| is_developer=1 | |
| else | |
| is_developer=0 | |
| echo "Author is not in developers team" | |
| fi | |
| echo "Check if author is in the staff team" | |
| if gh api \ | |
| -H "Accept: application/vnd.github+json" \ | |
| "/orgs/MariaDB/teams/staff/members/$author" \ | |
| 2>&1; then | |
| echo "Author is in staff team" | |
| is_foundation=1 | |
| else | |
| is_foundation=0 | |
| echo "Author is not in staff team" | |
| fi | |
| if [[ "$is_foundation" -ne 0 ]]; then | |
| label="MariaDB Foundation" | |
| else | |
| if [[ "$is_developer" -ne 0 ]]; then | |
| label="MariaDB Corporation" | |
| else | |
| label="External Contribution" | |
| fi | |
| fi | |
| echo "Applying label [$label] to PR#[$pr_number] by [$author]" | |
| #gh issue edit "$pr_number" \ | |
| # --repo "$REPO" \ | |
| # --add-label "$label" | |
| done |