Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2698d3f

Browse files
authored
ci: update pr checker (doocs#2103)
1 parent 07a0022 commit 2698d3f

File tree

1 file changed

+91
-61
lines changed

1 file changed

+91
-61
lines changed

.github/workflows/pr-checker.yml

Lines changed: 91 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -8,65 +8,95 @@ jobs:
88
build:
99
runs-on: ubuntu-latest
1010
steps:
11-
- name: Pull request
12-
uses: actions-cool/maintain-one-comment@v3
11+
- name: Check Team Membership
12+
id: check_team
13+
env:
14+
PR_OPENER: ${{ github.actor }}
15+
uses: actions/github-script@v5
1316
with:
14-
token: ${{ secrets.DOOCS_BOT_ACTION_TOKEN }}
15-
body: |
16-
🤭 感谢你的提交,请检查你的改动是否符合以下项目规范。
17-
18-
### 1. 格式化
19-
20-
我们项目中各种编程语言代码(包括文档)所采用的格式化工具不同,提交 pr 之前必须确保代码、文档正确格式化。
21-
22-
- .{md,js,ts,php,sql,rs} 采用 prettier
23-
- .{c,cpp,java} 采用 clang-format
24-
- .{py} 采用 black
25-
- .{go} 采用 gofmt
26-
- 其它待完善
27-
28-
### 2. Git 提交信息
29-
30-
我们项目遵循 [AngularJS Git Commit Message Conventions](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#) 规范,我们希望你的提交信息尽可能与项目保持一致。
31-
32-
- 新增或修改题解:feat: add/update solution(s) to lc problem(s): No.xxxx
33-
- 修复错误:fix: xxxx
34-
- 日常维护:chore: xxx
35-
36-
### 3. 其它补充
37-
38-
新增题解及代码时,需要创建 Solution.xxx 源代码文件(如果已存在,请确认算法是否更优,是则覆盖已有算法代码),同时,需要在 README.md 以及 README_EN.md 中添加对应的代码片段(英文文件中不要出现中文注释)
39-
40-
另外,编码风格(比如变量、函数的命名),尽量跟项目已有代码保持一致。
41-
42-
---
43-
44-
🤭 Thank you for your contribution. Please check if your changes comply with the following project specifications.
45-
46-
### 1. Formatting
47-
48-
We use different formatting tools for various programming languages (including documentation) in our project. You must ensure that the code and documentation are correctly formatted before submitting a pr.
49-
50-
- .{md,js,ts,php,sql,rs} use prettier
51-
- .{c,cpp,java} use clang-format
52-
- .{py} use black
53-
- .{go} use gofmt
54-
- Others to be improved
55-
56-
### 2. Git Commit Message
57-
58-
Our project follows the [AngularJS Git Commit Message Conventions](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#). We hope that your submission information is as consistent as possible with the project.
59-
60-
- Add or modify solutions: feat: add/update solution(s) to lc problem(s): No.xxxx
61-
- Fix errors: fix: xxxx
62-
- Routine maintenance: chore: xxx
63-
64-
### 3. Other notes
65-
66-
When adding solutions and code, you need to create a Solution.xxx source code file (if it already exists, please confirm whether the algorithm is better, if yes, overwrite the existing algorithm code), and at the same time, you need to add the corresponding code snippets in README.md and README_EN.md (do not have Chinese comments in the English file)
67-
68-
In addition, the coding style (such as the naming of variables and functions) should be as consistent as possible with the existing code in the project.
69-
70-
<!-- Sticky Pull Request Comment -->
71-
emojis: '+1, laugh'
72-
body-include: '<!-- Sticky Pull Request Comment -->'
17+
github-token: ${{ secrets.DOOCS_BOT_ACTION_TOKEN }}
18+
script: |
19+
const PR_OPENER = process.env.PR_OPENER;
20+
const comment =
21+
`🤭 感谢你的提交,请检查你的改动是否符合以下项目规范。
22+
23+
### 1. 格式化
24+
25+
我们项目中各种编程语言代码(包括文档)所采用的格式化工具不同,提交 pr 之前必须确保代码、文档正确格式化。
26+
27+
- .{md,js,ts,php,sql,rs} 采用 prettier
28+
- .{c,cpp,java} 采用 clang-format
29+
- .{py} 采用 black
30+
- .{go} 采用 gofmt
31+
- 其它待完善
32+
33+
### 2. Git 提交信息
34+
35+
我们项目遵循 [AngularJS Git Commit Message Conventions](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#) 规范,我们希望你的提交信息尽可能与项目保持一致。
36+
37+
- 新增或修改题解:feat: add/update solution(s) to lc problem(s): No.xxxx
38+
- 修复错误:fix: xxxx
39+
- 日常维护:chore: xxx
40+
41+
### 3. 其它补充
42+
43+
新增题解及代码时,需要创建 Solution.xxx 源代码文件(如果已存在,请确认算法是否更优,是则覆盖已有算法代码),同时,需要在 README.md 以及 README_EN.md 中添加对应的代码片段(英文文件中不要出现中文注释)
44+
另外,编码风格(比如变量、函数的命名),尽量跟项目已有代码保持一致。
45+
46+
---
47+
48+
🤭 Thank you for your contribution. Please check if your changes comply with the following project specifications.
49+
50+
### 1. Formatting
51+
52+
We use different formatting tools for various programming languages (including documentation) in our project. You must ensure that the code and documentation are correctly formatted before submitting a pr.
53+
54+
- .{md,js,ts,php,sql,rs} use prettier
55+
- .{c,cpp,java} use clang-format
56+
- .{py} use black
57+
- .{go} use gofmt
58+
- Others to be improved
59+
60+
### 2. Git Commit Message
61+
62+
Our project follows the [AngularJS Git Commit Message Conventions](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#). We hope that your submission information is as consistent as possible with the project.
63+
64+
- Add or modify solutions: feat: add/update solution(s) to lc problem(s): No.xxxx
65+
- Fix errors: fix: xxxx
66+
- Routine maintenance: chore: xxx
67+
68+
### 3. Other notes
69+
70+
When adding solutions and code, you need to create a Solution.xxx source code file (if it already exists, please confirm whether the algorithm is better, if yes, overwrite the existing algorithm code), and at the same time, you need to add the corresponding code snippets in README.md and README_EN.md (do not have Chinese comments in the English file)
71+
In addition, the coding style (such as the naming of variables and functions) should be as consistent as possible with the existing code in the project.
72+
<!-- Sticky Pull Request Comment -->`
73+
74+
const checkTeamMembership = async () => {
75+
try {
76+
const response = await github.request('GET /orgs/{org}/teams/{team_slug}/members', {
77+
org: 'doocs',
78+
team_slug: 'leetcode-algorithm',
79+
headers: {
80+
'X-GitHub-Api-Version': '2022-11-28'
81+
}
82+
})
83+
const teamMemberships = response.data;
84+
const isTeamMember = teamMemberships.some(member => member.login === PR_OPENER);
85+
if (isTeamMember) {
86+
console.log(`The user ${PR_OPENER} is a member of the team. Terminating with the workflow.`);
87+
return
88+
} else {
89+
console.log(`The user ${PR_OPENER} is not a member of the team. Proceeding the workflow.`);
90+
github.rest.issues.createComment({
91+
issue_number: context.issue.number,
92+
owner: context.repo.owner,
93+
repo: context.repo.repo,
94+
body: comment
95+
})
96+
}
97+
} catch (error) {
98+
console.log(PR_OPENER)
99+
console.log(error)
100+
}
101+
}
102+
checkTeamMembership();

0 commit comments

Comments
 (0)