Skip to content

Commit 48578c6

Browse files
committed
ci: add pull-request URL in commit emails
Use github API through `gh` to get the related pull-request URL and add them in the comment section of the emails. ChangeLog: * .github/workflows/send-emails.yml<prepare patch series>: Add PR links. Signed-off-by: Marc Poulhiès <[email protected]>
1 parent 9217c80 commit 48578c6

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

.github/workflows/send-emails.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,22 @@ jobs:
220220
echo ""
221221
222222
cp /tmp/description.txt "/tmp/tmp_descr.txt"
223-
echo "Commit on github: https://github.com/rust-GCC/gccrs/commit/$SHA1" >> "/tmp/tmp_descr.txt"
223+
echo "Commit on github: https://github.com/${{ github.repository }}/commit/$SHA1" >> /tmp/tmp_descr.txt
224+
225+
gh api "repos/${{ github.repository }}/commits/$SHA1/pulls" | \
226+
jq '.[].html_url' | \
227+
tr -d '"' | \
228+
sed 's/^/ - /'> /tmp/tmp_pr_links.txt
229+
230+
if [ -n /tmp/tmp_pr_links.txt ]; then
231+
echo "" >> /tmp/tmp_descr.txt
232+
echo "The commit has been mentionned in the following pull-request(s):" >> /tmp/tmp_descr.txt
233+
cat /tmp/tmp_pr_links.txt >> /tmp/tmp_descr.txt
234+
else
235+
echo "The commit is not linked to any pull-request" >> /tmp/tmp_descr.txt
236+
fi
237+
238+
echo >> /tmp/tmp_descr.txt
224239
225240
# insert the github header right after the '---'.
226241
sed '/^---$/ r /tmp/tmp_descr.txt' -i "$f"

0 commit comments

Comments
 (0)