-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (134 loc) · 4.76 KB
/
validate.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Marketplace Actions
on:
issues:
types:
- opened
- reopened
- edited
issue_comment:
types:
- created
- edited
jobs:
react-to-new-issue:
name: Post a comment to new issues
if: github.event_name == 'issues' && github.event.action == 'opened'
runs-on: ubuntu-latest
outputs:
comment-id: ${{ steps.comment.outputs.comment-id }}
steps:
- name: Add comment
id: comment
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.issue.number }}
body: |
感谢你的提交.
自动验证将在几分钟内开始.
is-revalidation:
if: github.event.issue.state == 'open' && github.event_name == 'issue_comment'
name: Verify if the comment is a revalidation request
runs-on: ubuntu-latest
steps:
- name: Run /validate command
env:
COMMENT_BODY: ${{ github.event.comment.body }}
run: |
command=$(echo "$COMMENT_BODY" | head -1)
if [[ $command != "/validate"* ]]; then
echo "No /validate command found in first line of the comment \"${command}\", skipping" >> $GITHUB_STEP_SUMMARY
exit 1
fi
- name: Add reactions
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ github.event.comment.id }}
reactions: '+1'
parse-issue:
needs: [ react-to-new-issue, is-revalidation ]
if: failure() == false && github.event.issue.state == 'open'
name: Parse Issue
runs-on: ubuntu-latest
env:
REPO: ${{ github.repository }}
ISSUE_NUM: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
outputs:
module_name: ${{ steps.set-output.outputs.module_name }}
pypi_name: ${{ steps.set-output.outputs.pypi_name }}
result: ${{ steps.run.outputs.result }}
output: ${{ steps.run.outputs.output }}
type: ${{ steps.run.outputs.type }}
name: ${{ steps.run.outputs.name }}
steps:
- name: Parse issue body
id: parse
uses: zentered/issue-forms-body-parser@v1.5.1
- name: Get Inputs
id: set-output
env:
JSON_DATA: ${{ steps.parse.outputs.data }}
run: |
module_name=$(echo $JSON_DATA | jq -r '.["module-name"].text' )
echo "module_name=$module_name" >> $GITHUB_OUTPUT
pypi_name=$(echo $JSON_DATA | jq -r '.["pypi-name"].text' )
echo "pypi_name=$pypi_name" >> $GITHUB_OUTPUT
# 启动py脚本环境,并传入module_name,pypi_name,ISSUE_TITLE
- uses: actions/checkout@v3.3.0
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Python script
id: run
env:
TITLE: ${{ env.ISSUE_TITLE }}
PYPI_NAME: ${{ steps.set-output.outputs.pypi_name }}
run: |
python .github/actions_scripts/parse.py
validation-failed:
runs-on: ubuntu-latest
needs: parse-issue
if: needs.parse-issue.outputs.result == 'error'
steps:
- uses: actions/checkout@v3.3.0
- name: Render template
id: render
uses: chuhlomin/render-template@v1.6
with:
template: .github/workflows/templates/validation-failed.md
vars: |
validation_output: ${{ needs.parse-issue.outputs.output }}
- name: Add comment
uses: peter-evans/create-or-update-comment@v3.0.2
with:
issue-number: ${{ github.event.issue.number }}
body: ${{ steps.render.outputs.result }}
- name: Remove label validation/succeeded
if: contains(github.event.issue.labels.*.name, 'validation/succeeded')
uses: actions/github-script@v6
with:
script: |
github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: ["validation/succeeded"]
})
- name: Add label validation/failed
if: contains(github.event.issue.labels.*.name, 'validation/failed') == false
uses: actions/github-script@v6
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["validation/failed"]
})
- name: Mark job as failed
run: exit 1