Skip to content

Commit d79e20a

Browse files
committed
ci: add email check
1 parent 68afc23 commit d79e20a

File tree

3 files changed

+85
-1
lines changed

3 files changed

+85
-1
lines changed

.github/email-blacklist.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*@qq.com
2+
*@foxmail.com
3+
*@126.com
4+
*@163.com
5+
*@sina.com
6+
MX:mxbiz1.qq.com

.github/workflows/ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,20 @@ jobs:
346346
cat version.txt
347347
348348
- name: Clean git tag & release
349+
if: startsWith(github.ref, 'refs/heads/master')
349350
run: |
350351
gh release delete latest --cleanup-tag --yes --repo $GITHUB_REPOSITORY || true
351352
# Move latest tag to current commit locally
352-
git tag latest -f
353+
git tag latest -f || true
353354
env:
354355
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
355356

357+
- name: Clean git tag
358+
if: startsWith(github.ref, 'refs/tags/v')
359+
run: |
360+
# Delete latest tag locally (for git-cliff)
361+
git tag -d latest || true
362+
356363
- name: Generate a changelog
357364
uses: orhun/git-cliff-action@main
358365
id: git-cliff

.github/workflows/email-check.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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

Comments
 (0)