-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Add github workflow that checks if a private email address was used to contribute to the repo and warn in this case #80514
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| name: "Check for private emails used in PRs" | ||
| on: pull_request_target | ||
| permissions: | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| validate_email: | ||
| runs-on: ubuntu-latest | ||
| if: github.repository == 'llvm/llvm-project' | ||
| steps: | ||
| - name: Fetch LLVM sources | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.sha }} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this getting the whole repo each time? I wonder if there are some "shallow checkout" options that would apply here. Or we could get it from the PR event, maybe, but I guess you already looked for that and I don't want to derail the chosen solution.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is And possibly this could all be done in the YAML. Which is not necessarily a good thing so you don't have to change what you've got. Just know that this is (allegedly) an option.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Emails could come from different places, but we mostly bother about email of author in the commit (which has to set up manually from via |
||
|
|
||
| - name: Extract author email | ||
| id: author | ||
| run: | | ||
| git log -1 | ||
| echo "EMAIL=$(git show -s --format='%ae' HEAD~0)" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Validate author email | ||
| if: ${{ endsWith(steps.author.outputs.EMAIL, 'noreply.github.com') }} | ||
| uses: actions/github-script@v6 | ||
| env: | ||
| EMAIL: ${{ steps.author.outputs.EMAIL }} | ||
| with: | ||
| script: | | ||
| const { EMAIL } = process.env | ||
| await github.rest.issues.createComment({ | ||
| issue_number: context.issue.number, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: `⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo. | ||
| Please turn off [Keep my email addresses private](https://github.com/settings/emails) setting in your account. | ||
| `}) | ||
Uh oh!
There was an error while loading. Please reload this page.