File tree Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Original file line number Diff line number Diff line change 4
4
pull_request :
5
5
types :
6
6
- opened
7
+ - reopened
7
8
8
9
permissions :
9
10
contents : read
@@ -20,14 +21,33 @@ jobs:
20
21
21
22
- name : Extract author email
22
23
id : author
24
+ env :
25
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
23
26
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
+
26
43
# Create empty comment file
27
44
echo "[]" > comments
28
45
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.
29
49
- name : Validate author email
30
- if : ${{ endsWith( steps.author.outputs.EMAIL, 'noreply.github.com') }}
50
+ if : ${{ steps.author.outputs.EMAIL_AUTHOR_GH_UI == '' }}
31
51
env :
32
52
COMMENT : >-
33
53
⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.<br/>
You can’t perform that action at this time.
0 commit comments