Skip to content

Commit 7f955b0

Browse files
committed
[workflows] Fix release note request workflow
We need to use the issue-write workflow to write the comments, because pull_request targets don't have permissions to write comments.
1 parent 5e0fc93 commit 7f955b0

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

.github/workflows/issue-write.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
workflows:
66
- "Check code formatting"
77
- "Check for private emails used in PRs"
8+
- "PR Request Release Note"
89
types:
910
- completed
1011

.github/workflows/pr-request-release-note.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: PR Request Release Note
22

33
permissions:
44
contents: read
5-
pull-requests: write
65

76
on:
87
pull_request:
@@ -41,3 +40,11 @@ jobs:
4140
--token "$GITHUB_TOKEN" \
4241
request-release-note \
4342
--pr-number ${{ github.event.pull_request.number}}
43+
44+
45+
- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
46+
if: always()
47+
with:
48+
name: workflow-args
49+
path: |
50+
comments

llvm/utils/git/github-automation.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import argparse
1212
from git import Repo # type: ignore
1313
import html
14+
import json
1415
import github
1516
import os
1617
import re
@@ -653,7 +654,15 @@ def request_release_note(token: str, repo_name: str, pr_number: int):
653654
mention = f"@{submitter}"
654655

655656
comment = f"{mention} (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. "
656-
pr.as_issue().create_comment(comment)
657+
try:
658+
pr.as_issue().create_comment(comment)
659+
except:
660+
# Failed to create comment so emit file instead
661+
with open("comments", "w") as file:
662+
data = [
663+
{"body" : comment}
664+
]
665+
json.dump(data, file)
657666

658667

659668
parser = argparse.ArgumentParser()

0 commit comments

Comments
 (0)