Skip to content

Commit 067882c

Browse files
authored
Add github workflow that checks if a private email address was used to contribute to the repo and warn in this case (#80514)
Following the Discourse discussion, warn in case of a private email address was used in a PR.
1 parent b53169d commit 067882c

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

.github/workflows/email-check.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: "Check for private emails used in PRs"
2+
3+
on: pull_request_target
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
validate_email:
10+
permissions:
11+
pull-requests: write
12+
runs-on: ubuntu-latest
13+
if: github.repository == 'llvm/llvm-project'
14+
steps:
15+
- name: Fetch LLVM sources
16+
uses: actions/checkout@v4
17+
with:
18+
ref: ${{ github.event.pull_request.head.sha }}
19+
20+
- name: Extract author email
21+
id: author
22+
run: |
23+
git log -1
24+
echo "EMAIL=$(git show -s --format='%ae' HEAD~0)" >> $GITHUB_OUTPUT
25+
26+
- name: Validate author email
27+
if: ${{ endsWith(steps.author.outputs.EMAIL, 'noreply.github.com') }}
28+
uses: actions/github-script@v6
29+
env:
30+
EMAIL: ${{ steps.author.outputs.EMAIL }}
31+
with:
32+
script: |
33+
const { EMAIL } = process.env
34+
await github.rest.issues.createComment({
35+
issue_number: context.issue.number,
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
body: `⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
39+
Please turn off [Keep my email addresses private](https://github.com/settings/emails) setting in your account.
40+
`})

0 commit comments

Comments
 (0)