Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/commit-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Git Commit Angular Style Check

on:
pull_request:
types: [ opened, synchronize, reopened ]

jobs:
commit-check:
runs-on: ubuntu-latest
steps:
- name: Checkout 喵喵代码
uses: actions/checkout@v2

- name: 获取提交信息
id: get_commits
run: |
echo "喵~ 正在获取提交信息呢~"
git fetch --no-tags origin ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}
COMMITS=$(git log --pretty=format:"%s" ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }})
echo "找到以下提交:"
echo "$COMMITS"
echo "messages<<EOF" >> $GITHUB_OUTPUT
echo "$COMMITS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: 检查提交信息是否符合 Angular 规范
id: check_commits
continue-on-error: true
run: |
echo "喵~ 开始检查提交信息啦~"
PATTERN='^(feat|fix|docs|style|refactor|perf|test|chore|ci)(\([a-zA-Z0-9\-]+\))?: .+'
FAIL=0
while IFS= read -r line; do
if [[ ! $line =~ $PATTERN ]]; then
echo "❌ 无效的提交信息: $line"
FAIL=1
fi
done <<< "${{ steps.get_commits.outputs.messages }}"
if [ $FAIL -eq 1 ]; then
echo "::set-output name=result::fail"
exit 1
else
echo "::set-output name=result::pass"
fi

- name: 如果提交不符合规范,则自动关闭 PR
if: steps.check_commits.outputs.result == 'fail'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "喵~ 检测到有无效的提交信息,正在关闭该 PR 呀~"
PR_NUMBER=${{ github.event.pull_request.number }}
curl -X PATCH \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER \
-d '{"state": "closed"}'
28 changes: 28 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,34 @@ python3 app.py
| DB_NAME | 数据库名 | emby_bot_db |
| ADMIN_LIST | Bot 管理员的 Telegram ID 列表(用逗号分隔) | 123456789,987654321 |

## 贡献指南
欢迎贡献代码!为了确保项目的高质量和一致性,请遵循以下贡献规程:
### 提交规范
- 提交信息必须符合 Angular 提交信息规范,格式如下:
- `type(scope): description`
- 例如:`feat(user): 添加用户注册功能`
### 与数据库、API 代码相关的更改
- 请确保所有更改都经过严格的测试,并且不会引入新的错误。
### 创建 Pull Request
- 请确保创建 Pull Request 前进行本地测试,确保通过所有 CI/CD 测试。
### 支持的 Type 列表

| Type | 描述 |
|----------|-------------------------------------------------------------|
| feat | 添加新功能,比如新增用户注册、功能扩展等 |
| fix | 修复 bug 或错误,解决问题的修改 |
| docs | 文档相关修改,如更新说明文档、README、注释等 |
| style | 代码格式、标点、空格等修改,不影响代码逻辑运行 |
| refactor | 代码重构,调整代码结构而不改变功能 |
| perf | 性能优化修改,提升效率或降低资源消耗 |
| test | 添加或更新测试代码,保证项目稳定性 |
| chore | 杂项维护,如依赖更新、构建脚本修改,不涉及代码逻辑 |
| ci | 持续集成相关修改,如 GitHub Actions 工作流程优化 |

---
感谢您的贡献!


### Thanks
- [Pyrogram](https://docs.pyrogram.org/) - Telegram API for Python
- [SQLAlchemy](https://www.sqlalchemy.org/) - Python SQL Toolkit and Object-Relational Mapping
Expand Down