mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-26 19:35:12 +00:00
.github/script/label_promoted_commit.py: add label only if ref is PR
we got a failure during check-commit action: ``` Run python .github/scripts/label_promoted_commits.py --commit_before_merge30e82a81e8--commit_after_mergef31d5e3204--repository scylladb/scylladb --ref refs/heads/master Commit sha is:d5a149fc01Commit sha is:415457be2bCommit sha is:d3b1ccd03aCommit sha is:1fca341514Commit sha is:f784be6a7eCommit sha is:80986c17c3Commit sha is:492d0a5c86Commit sha is:7b3f55a65fCommit sha is:78d6471ce4Commit sha is:7a69d9070fCommit sha is:a9e985fcc9master branch, pr number is: 19213 Traceback (most recent call last): File "/home/runner/work/scylladb/scylladb/.github/scripts/label_promoted_commits.py", line 87, in <module> main() File "/home/runner/work/scylladb/scylladb/.github/scripts/label_promoted_commits.py", line 81, in main pr = repo.get_pull(pr_number) File "/usr/lib/python3/dist-packages/github/Repository.py", line 2746, in get_pull headers, data = self._requester.requestJsonAndCheck( File "/usr/lib/python3/dist-packages/github/Requester.py", line 353, in requestJsonAndCheck return self.__check( File "/usr/lib/python3/dist-packages/github/Requester.py", line 378, in __check raise self.__createException(status, responseHeaders, output) github.GithubException.UnknownObjectException: 404 {"message": "Not Found", "documentation_url": "https://docs.github.com/rest/pulls/pulls#get-a-pull-request", "status": "404"} Error: Process completed with exit code 1. ``` The reason for this failure is since in one of the promoted commits (a9e985fcc9) had a reference of `Closes` to an issue. Fixes: https://github.com/scylladb/scylladb/issues/19677 (cherry picked from commite33126fc3e) Closes scylladb/scylladb#19690
This commit is contained in:
committed by
Botond Dénes
parent
c33556c0f1
commit
c20f5c8408
12
.github/scripts/label_promoted_commits.py
vendored
12
.github/scripts/label_promoted_commits.py
vendored
@@ -1,8 +1,9 @@
|
||||
from github import Github
|
||||
import argparse
|
||||
import re
|
||||
import sys
|
||||
import os
|
||||
from github import Github
|
||||
from github.GithubException import UnknownObjectException
|
||||
|
||||
try:
|
||||
github_token = os.environ["GITHUB_TOKEN"]
|
||||
@@ -77,9 +78,12 @@ def main():
|
||||
comment = f'Closed via {commit.sha}'
|
||||
add_comment_and_close_pr(pr, comment)
|
||||
else:
|
||||
print(f'master branch, pr number is: {pr_number}')
|
||||
pr = repo.get_pull(pr_number)
|
||||
pr.add_to_labels('promoted-to-master')
|
||||
try:
|
||||
pr = repo.get_pull(pr_number)
|
||||
pr.add_to_labels('promoted-to-master')
|
||||
print(f'master branch, pr number is: {pr_number}')
|
||||
except UnknownObjectException:
|
||||
print(f'{pr_number} is not a PR but an issue, no need to add label')
|
||||
processed_prs.add(pr_number)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user