Skip to content

[CI] Fix detecting usage of private emails #19394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions .github/workflows/email-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,30 @@ jobs:

- name: Extract author email
id: author
env:
GH_TOKEN: ${{ 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 because this takes into account the GitHub settings for email privacy.
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" --jq '.data.user.email')
echo "EMAIL_AUTHOR_GH_UI=$email" >> "$GITHUB_OUTPUT"

# 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/>
Expand All @@ -39,6 +55,9 @@ jobs:
[{"body" : "$COMMENT"}]
EOF

# Fail this job.
false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did we have this part upstream? or they didnt want it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's not a part of upstream as of now. But, as per llvm/llvm-project#148694 (comment), I'll be making a separate PR to make the workflow fail in the upstream.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it, thanks


- uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
if: always()
with:
Expand Down
Loading