[llvm] [CI] Make email check workflow fail when author's email is private in Github UI (PR #148694)

Udit Kumar Agarwal via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 14 15:52:41 PDT 2025


https://github.com/uditagarwal97 updated https://github.com/llvm/llvm-project/pull/148694

>From bbde668c3d6110fe03fb4f182ec0acbfefde5924 Mon Sep 17 00:00:00 2001
From: "Agarwal, Udit" <udit.agarwal at intel.com>
Date: Thu, 10 Jul 2025 21:10:36 +0200
Subject: [PATCH] Fix workflow

Signed-off-by: Agarwal, Udit <udit.agarwal at intel.com>
---
 .github/workflows/email-check.yaml | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/email-check.yaml b/.github/workflows/email-check.yaml
index 904ad718f97dd..9907f9d198470 100644
--- a/.github/workflows/email-check.yaml
+++ b/.github/workflows/email-check.yaml
@@ -4,6 +4,7 @@ on:
   pull_request:
     types:
       - opened
+      - reopened
 
 permissions:
   contents: read
@@ -20,14 +21,33 @@ jobs:
 
       - name: Extract author email
         id: author
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         run: |
-          git log -1
-          echo "EMAIL=$(git show -s --format='%ae' HEAD~0)" >> $GITHUB_OUTPUT
+          # Use Github GraphQL APIs to get the email associated with the PR author.
+          query='
+          query($login: String!) {
+            user(login: $login) {
+              email
+            }
+          }'
+
+          PR_AUTHOR=${{ github.event.pull_request.user.login }}
+
+          email=$(gh api graphql -f login="$PR_AUTHOR" -f query="$query" -H "Authorization: Bearer $GITHUB_TOKEN" --jq '.data.user.email')
+          echo "EMAIL_AUTHOR_GH_UI=$email" >> "$GITHUB_OUTPUT"
+
+          # Print the email to the log for debugging purposes.
+          echo "GitHub user's email: $email"
+
           # Create empty comment file
           echo "[]" > comments
 
+      # When EMAIL_AUTHOR_GH_UI is NULL, author's email is hidden in GitHub UI.
+      # In this case, we warn the user to turn off "Keep my email addresses private"
+      # setting in their account.
       - name: Validate author email
-        if: ${{ endsWith(steps.author.outputs.EMAIL, 'noreply.github.com')  }}
+        if: ${{ steps.author.outputs.EMAIL_AUTHOR_GH_UI == '' }}
         env:
           COMMENT: >-
             ⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.<br/>



More information about the llvm-commits mailing list