|
| 1 | +name: Commit Email Check |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize, reopened] |
| 6 | + |
| 7 | +jobs: |
| 8 | + validate: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + permissions: |
| 11 | + contents: read |
| 12 | + pull-requests: write |
| 13 | + issues: write |
| 14 | + steps: |
| 15 | + - name: Checkout PR branch |
| 16 | + uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + |
| 20 | + - name: Extract commit emails |
| 21 | + run: | |
| 22 | + BASE_SHA=${{ github.event.pull_request.base.sha }} |
| 23 | + HEAD_SHA=${{ github.event.pull_request.head.sha }} |
| 24 | + git log --format='%ae' $BASE_SHA..$HEAD_SHA | sort -u > commit-emails.txt |
| 25 | +
|
| 26 | + - uses: taiki-e/install-action@v2 |
| 27 | + with: |
| 28 | + tool: check-commits-email |
| 29 | + |
| 30 | + - name: Run validation |
| 31 | + id: check |
| 32 | + run: | |
| 33 | + check-commits-email \ |
| 34 | + --rules .github/email-blacklist.txt \ |
| 35 | + --emails commit-emails.txt \ |
| 36 | + --output github >> $GITHUB_OUTPUT |
| 37 | +
|
| 38 | + - name: Post comment |
| 39 | + if: steps.check.outputs.violations != '' |
| 40 | + uses: peter-evans/create-or-update-comment@v4 |
| 41 | + with: |
| 42 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + issue-number: ${{ github.event.pull_request.number }} |
| 44 | + comment-id: email-check-${{ github.event.pull_request.number }} |
| 45 | + edit-mode: replace |
| 46 | + body: | |
| 47 | + ### ⚠️ Violation of email address detected |
| 48 | + The following mailboxes match the blacklist rule: |
| 49 | +
|
| 50 | + ${{ steps.check.outputs.violations }} |
| 51 | +
|
| 52 | + **Correction steps**: |
| 53 | + 1. Close pull request and wait for delete @Watfaq/clash-rs-devs |
| 54 | +
|
| 55 | + 2. Modifying author information using interactive rebase |
| 56 | + ```bash |
| 57 | + git rebase -i HEAD~${{ github.event.pull_request.commits }} |
| 58 | + # Mark the commit that needs to be modified as edit |
| 59 | + ``` |
| 60 | +
|
| 61 | + 3. For each marked commit, execute: |
| 62 | + ```bash |
| 63 | + git commit --amend --author="合法姓名 <正确邮箱>" |
| 64 | + git rebase --continue |
| 65 | + ``` |
| 66 | + 4. Force push update branch |
| 67 | + ```bash |
| 68 | + git push --force-with-lease |
| 69 | + ``` |
| 70 | + 5. Open another pull request |
| 71 | +
|
0 commit comments