Skip to content

Commit

Permalink
ci: 更新 Git 提交的用户信息
Browse files Browse the repository at this point in the history
- 将用户邮箱从 "admin@icodeq.com" 修改为 "41898282+github-actions[bot]@users.noreply.github.com"
- 将用户名从 "zkeq" 修改为 "github-actions[bot]"
  • Loading branch information
zkeq committed Dec 23, 2024
1 parent 951c3ec commit 3a85201
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
- name: Commit ALL IN ONE files
run: |
git config --local user.email "admin@icodeq.com"
git config --local user.name "zkeq"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git commit -m "GitHub Actions Crawler ALL IN ONE at $(date +'%Y-%m-%d %H:%M:%S')"
Expand Down
35 changes: 35 additions & 0 deletions change-author.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python3
import subprocess
import os
import re

# 定义要匹配的提交信息模式
commit_pattern = r"GitHub Actions Crawler ALL IN ONE at \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}"

# 创建环境变量设置命令
new_env = {
'GIT_AUTHOR_NAME': 'github-actions[bot]',
'GIT_AUTHOR_EMAIL': '41898282+github-actions[bot]@users.noreply.github.com',
'GIT_COMMITTER_NAME': 'github-actions[bot]',
'GIT_COMMITTER_EMAIL': '41898282+github-actions[bot]@users.noreply.github.com'
}

# 使用 git filter-branch
cmd = '''
git filter-branch -f --env-filter '
COMMIT_MSG=$(git log --format=%B -n 1 $GIT_COMMIT)
if [[ $COMMIT_MSG =~ "GitHub Actions Crawler ALL IN ONE at" ]]; then
export GIT_AUTHOR_NAME="github-actions[bot]"
export GIT_AUTHOR_EMAIL="41898282+github-actions[bot]@users.noreply.github.com"
export GIT_COMMITTER_NAME="github-actions[bot]"
export GIT_COMMITTER_EMAIL="41898282+github-actions[bot]@users.noreply.github.com"
else
export GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME"
export GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL"
export GIT_COMMITTER_NAME="$GIT_COMMITTER_NAME"
export GIT_COMMITTER_EMAIL="$GIT_COMMITTER_EMAIL"
fi
' --tag-name-filter cat -- --all
'''

subprocess.run(cmd, shell=True)

0 comments on commit 3a85201

Please sign in to comment.