Skip to content

Commit 286721c

Browse files
committed
update actions
1 parent 7c34a23 commit 286721c

4 files changed

Lines changed: 38 additions & 17 deletions

File tree

.github/ISSUE_TEMPLATE/T1_bug.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: 报告转换器错误❌
22
description: 使用转换器时遇到问题?请告诉我们!
33
title: "[Bug]: "
4-
labels: ["bug"]
4+
labels: ["bug", "from template"]
55
body:
66
- type: checkboxes
77
id: what-happened

.github/ISSUE_TEMPLATE/T2_enhancement.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: 请求支持新功能💪
22
description: 为现有转换器添加新功能。
33
title: "[Enhancement]: "
4-
labels: ["enhancement"]
4+
labels: ["enhancement", "from template"]
55
assignees:
66
- jiaojiaodubai
77
body:

.github/ISSUE_TEMPLATE/T3_new_translator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: 申请新转换器🙋‍♂️
22
description: 申请新的转换器,使Zotero能够从新的网站或文献交换格式导入,或者导出为新的文献交换格式。
33
title: "[New]: "
4-
labels: ["new translator"]
4+
labels: ["new translator", "from template"]
55
body:
66
- type: markdown
77
attributes:

.github/workflows/validate-issues.yaml

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ jobs:
1111
name: Validate Issue with Custom Logic
1212
runs-on: ubuntu-latest
1313

14-
# These permissions are required to read custom validator scripts and
15-
# write/update issue comments.
1614
permissions:
1715
contents: read
1816
issues: write
@@ -25,45 +23,68 @@ jobs:
2523
- name: Install GitHub CLI
2624
run: sudo apt-get install gh
2725

28-
- name: Validate Issue Title Format
29-
id: title-check
26+
- name: Validate Title
3027
run: |
31-
if [[ ! "${{ github.event.issue.title }}" =~ ^\[(New|Bug|Enhancement)\]:\ ]]; then
32-
gh issue edit ${{ github.event.issue.number }} --add-label invalid
33-
gh issue close ${{ github.event.issue.number }} --comment "由于标题不符合要求,已自动关闭 issue。" --reason "completed"
28+
labels=(${{ toJSON(github.event.issue.labels) }})
29+
is_from_template=false
30+
for label in "${labels[@]}"
31+
do
32+
if [[ "$label" == "from template" ]]; then
33+
is_from_template=true
34+
if [[ ! "${{ github.event.issue.title }}" =~ ^\[(New|Bug|Enhancement)\]:\ ]]; then
35+
gh issue edit ${{ github.event.issue.number }} --add-label invalid
36+
gh issue close ${{ github.event.issue.number }} --comment "由于标题不符合要求,已自动关闭 issue。" --reason "completed"
37+
exit 0
38+
fi
39+
fi
40+
done
41+
42+
if [[ "$is_from_template" == "true" ]]; then
43+
template="unknown"
44+
for label in "${labels[@]}"
45+
do
46+
if [[ "$label" == "bug" ]]; then
47+
template="T1_bug.yaml"
48+
elif [[ "$label" == "enhancement" ]]; then
49+
template="T2_enhancement.yaml"
50+
elif [[ "$label" == "new translator" ]]; then
51+
template="T3_new_translator.yaml"
52+
done
53+
if [[ "$template" == "unknown" ]]; then
54+
echo "This issue does not use a recognized template, skipping validation."
55+
exit 0
56+
fi
57+
echo "template=${template}" >> $GITHUB_ENV
58+
else [[ "$is_from_template" == "false" ]]; then
59+
echo "This issue does not use a template, skipping validation."
3460
exit 0
3561
fi
3662
env:
3763
GH_TOKEN: ${{ github.token }}
3864

39-
# Install Node.js on the runner.
4065
- name: Setup Node.js
4166
id: setup-node
4267
uses: actions/setup-node@v4
4368
with:
4469
node-version: 20
4570

46-
# Install dependencies from `package.json`.
4771
- name: Install Dependencies
4872
id: install
4973
run: npm install
5074

51-
# Parse the issue body and convert it to JSON.
5275
- name: Parse Issue Body
5376
id: parse
5477
uses: issue-ops/parser@v4
5578
with:
5679
body: ${{ github.event.issue.body }}
57-
issue-form-template: T3_new_translator.yaml
80+
issue-form-template: ${{ env.template }}
5881
workspace: ${{ github.workspace }}
5982

60-
# Validate the parsed issue body against the issue form template. This
61-
# example does use custom validators.
6283
- name: Validate Issue Forms
6384
id: validate
6485
uses: issue-ops/validator@v3
6586
with:
66-
issue-form-template: T3_new_translator.yaml
87+
issue-form-template: ${{ env.template }}
6788
parsed-issue-body: ${{ steps.parse.outputs.json }}
6889
workspace: ${{ github.workspace }}
6990

0 commit comments

Comments
 (0)