summaryrefslogtreecommitdiff
path: root/.github/workflows/email-check.yaml
blob: ba625b2b3b0626aca7bf0387d1bd9009b3e85e40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name: "Check for private emails used in PRs"

on:
  pull_request:
    types:
      - opened

permissions:
  contents: read

jobs:
  validate_email:
    runs-on: ubuntu-24.04
    if: github.repository == 'llvm/llvm-project'
    steps:
      - name: Fetch LLVM sources
        uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
        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
          # Create empty comment file
          echo "[]" > comments

      - name: Validate author email
        if: ${{ endsWith(steps.author.outputs.EMAIL, 'noreply.github.com')  }}
        env:
          COMMENT: >-
            ⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.<br/>
            Please turn off [Keep my email addresses private](https://github.com/settings/emails) setting in your account.<br/>
            See [LLVM Developer Policy](https://llvm.org/docs/DeveloperPolicy.html#email-addresses) and
            [LLVM Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it) for more information.
        run: |
          cat << EOF > comments
          [{"body" : "$COMMENT"}]
          EOF

      - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
        if: always()
        with:
          name: workflow-args
          path: |
            comments