Skip to content

Commit 95f27b1

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 <dkm@kataplop.net>
1 parent b9f3a40 commit 95f27b1

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

.github/workflows/send-emails.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,24 @@ 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 [ -s /tmp/tmp_pr_links.txt ]; then
229+
echo -e "\nThe commit has been mentionned in the following pull-request(s):" >> /tmp/tmp_descr.txt
230+
231+
tr -d '"' < /tmp/tmp_pr_links.txt | \
232+
sed 's/^/ - /' >> /tmp/tmp_descr.txt
233+
else
234+
echo "The commit is not linked to any pull-request" >> /tmp/tmp_descr.txt
235+
fi
236+
else
237+
echo "There was an error fetching data from github API for getting PR for commit" | tee -a "$GITHUB_STEP_SUMMARY"
238+
fi
239+
240+
echo >> /tmp/tmp_descr.txt
224241
225242
# insert the github header right after the '---'.
226243
sed '/^---$/ r /tmp/tmp_descr.txt' -i "$f"

0 commit comments

Comments
 (0)