[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)

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-github-workflow

Author: Anton Korobeynikov (asl)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/80514.diff


1 Files Affected:

- (added) .github/workflows/email-check.yaml (+36) 


``````````diff
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.
+            `})

``````````

</details>


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


More information about the llvm-commits mailing list