[llvm] Add github workflow that checks if a private email address was used to contribute to the repo and warn in this case (PR #80514)

Anton Korobeynikov via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 2 16:06:07 PST 2024


https://github.com/asl created https://github.com/llvm/llvm-project/pull/80514

Following the Discourse discussion, warn in case of a private email address was used in a PR.

>From 5e96af1ac05eb479cae8ca0c04dc036d8c619ea5 Mon Sep 17 00:00:00 2001
From: Anton Korobeynikov <anton at korobeynikov.info>
Date: Fri, 2 Feb 2024 16:03:15 -0800
Subject: [PATCH] Add github workflow that checks if a private email address
 was used to contribute to the repo and warn in this case.

---
 .github/workflows/email-check.yaml | 36 ++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 .github/workflows/email-check.yaml

diff --git a/.github/workflows/email-check.yaml b/.github/workflows/email-check.yaml
new file mode 100644
index 0000000000000..4b729ddfa42d5
--- /dev/null
+++ b/.github/workflows/email-check.yaml
@@ -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 at v4
+        with:
+          ref: ${{ github.event.pull_request.head.sha }}
+
+      - 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 at 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.
+            `})



More information about the llvm-commits mailing list