Skip to content

Commit bbde668

Browse files
committed
Fix workflow
Signed-off-by: Agarwal, Udit <[email protected]>
1 parent 76f1ddc commit bbde668

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

.github/workflows/email-check.yaml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
pull_request:
55
types:
66
- opened
7+
- reopened
78

89
permissions:
910
contents: read
@@ -20,14 +21,33 @@ jobs:
2021

2122
- name: Extract author email
2223
id: author
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2326
run: |
24-
git log -1
25-
echo "EMAIL=$(git show -s --format='%ae' HEAD~0)" >> $GITHUB_OUTPUT
27+
# Use Github GraphQL APIs to get the email associated with the PR author.
28+
query='
29+
query($login: String!) {
30+
user(login: $login) {
31+
email
32+
}
33+
}'
34+
35+
PR_AUTHOR=${{ github.event.pull_request.user.login }}
36+
37+
email=$(gh api graphql -f login="$PR_AUTHOR" -f query="$query" -H "Authorization: Bearer $GITHUB_TOKEN" --jq '.data.user.email')
38+
echo "EMAIL_AUTHOR_GH_UI=$email" >> "$GITHUB_OUTPUT"
39+
40+
# Print the email to the log for debugging purposes.
41+
echo "GitHub user's email: $email"
42+
2643
# Create empty comment file
2744
echo "[]" > comments
2845
46+
# When EMAIL_AUTHOR_GH_UI is NULL, author's email is hidden in GitHub UI.
47+
# In this case, we warn the user to turn off "Keep my email addresses private"
48+
# setting in their account.
2949
- name: Validate author email
30-
if: ${{ endsWith(steps.author.outputs.EMAIL, 'noreply.github.com') }}
50+
if: ${{ steps.author.outputs.EMAIL_AUTHOR_GH_UI == '' }}
3151
env:
3252
COMMENT: >-
3353
⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.<br/>

0 commit comments

Comments
 (0)