-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
MDEV-38546: Automatically assign labels to lablesess PRs #4536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+85
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| 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 | ||
| nfailed=0 | ||
|
|
||
| # List first 200 PRs lacking classification labels as JSON | ||
| gh pr list \ | ||
| --repo "$REPO" \ | ||
| --search 'is:pr -label:"External Contribution" -label:"MariaDB Foundation" -label:"MariaDB Corporation" -label="Codership"' \ | ||
| --limit 200 \ | ||
| --json number,createdAt,labels,author | | ||
| jq -c '.[]' | | ||
| while read -r pr; do | ||
| pr_number=$(echo "$pr" | jq -r '.number') | ||
| created_at=$(echo "$pr" | jq -r '.createdAt') | ||
| label_count=$(echo "$pr" | jq '.labels | length') | ||
| author=$(echo "$pr" | jq -r '.author.login') | ||
|
|
||
| echo "Evaluating PR #$pr_number by $author" | ||
|
|
||
| # Check if author is in the developers team | ||
| if gh api \ | ||
| -H "Accept: application/vnd.github+json" \ | ||
| "/orgs/MariaDB/teams/developers/members/$author" \ | ||
| >/dev/null 2>&1; then | ||
| echo "Author is in developers team" | ||
| is_developer=1 | ||
| else | ||
| is_developer=0 | ||
| echo "Author is not in developers team" | ||
| fi | ||
| # Check if author is in the staff team | ||
| if gh api \ | ||
| -H "Accept: application/vnd.github+json" \ | ||
| "/orgs/MariaDB/teams/staff/members/$author" \ | ||
| >/dev/null 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 | ||
RazvanLiviuVarzaru marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if [[ "$is_developer" -ne 0 ]]; then | ||
| label="MariaDB Corporation" | ||
| else | ||
| label="External Contribution" | ||
| fi | ||
| fi | ||
|
|
||
| # start soft: read-only first. | ||
| echo "Should apply label [$label] to PR#[$pr_number] by [$author]" | ||
|
|
||
| # echo "Applying label $label" | ||
| # if gh issue edit "$pr_number" \ | ||
| # --repo "$REPO" \ | ||
| # --add-label "$label"; then | ||
| # echo "**FAILED applying label [$label] to PR#[$pr_number] by [$author]" | ||
| # nfailed=$((nfailed + 1)) | ||
| # fi | ||
| done | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.