Skip to content

Commit d2d0c21

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 d2d0c21

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

.github/workflows/send-emails.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,25 @@ 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+
if gh api "repos/${{ github.repository }}/commits/$SHA1/pulls" | \
226+
jq '.[].html_url' > /tmp/tmp_pr_links.txt;
227+
then
228+
if [ -n /tmp/tmp_pr_links.txt ]; then
229+
echo "" >> /tmp/tmp_descr.txt
230+
echo "The commit has been mentionned in the following pull-request(s):" >> /tmp/tmp_descr.txt
231+
232+
tr -d '"' < /tmp/tmp_pr_links.txt | \
233+
sed 's/^/ - /' >> /tmp/tmp_descr.txt
234+
else
235+
echo "The commit is not linked to any pull-request" >> /tmp/tmp_descr.txt
236+
fi
237+
else
238+
echo "There was an error fetching data from github API for getting PR for commit" | tee -a $GITHUB_STEP_SUMMARY
239+
fi
240+
241+
echo >> /tmp/tmp_descr.txt
224242
225243
# insert the github header right after the '---'.
226244
sed '/^---$/ r /tmp/tmp_descr.txt' -i "$f"

0 commit comments

Comments
 (0)