-
Notifications
You must be signed in to change notification settings - Fork 0
216 lines (193 loc) · 7.23 KB
/
ic.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
name: Issue Check
on:
issues:
types:
- opened
- reopened
- edited
issue_comment:
types:
- created
- edited
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GH_REPO: ${{ secrets.GH_REPO }}
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
if: env.ACT == false
id: comment
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.issue.number }}
body: |
Thank you for submitting your plugin.
The validation of your submission will start soon.
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
if: env.ACT == false
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: Ensure Terms of Service are accepted
runs-on: ubuntu-latest
outputs:
accepted: ${{ steps.set-output.outputs.accepted }}
steps:
- name: Parse issue body
id: parse
uses: zentered/issue-forms-body-parser@v2.1.1
- name: Find checkbox state
id: set-output
env:
JSON_DATA: ${{ steps.parse.outputs.data }}
run: |
accepted=$(echo $JSON_DATA | jq -r '.["terms-of-services"].list[0].checked')
echo "accepted=$accepted" >> $GITHUB_OUTPUT
- name: Validate
if: steps.set-output.outputs.accepted == 'null'
env:
PARSED_DATA: ${{ steps.parse.outputs.data }}
run: |
# Check if $GITHUB_STEP_SUMMARY exist to avoid the following lines to error when running with act
if [[ -w "$GITHUB_STEP_SUMMARY" ]]; then
echo "No checkbox for the plugin found in the body of the issue ${{ inputs.issue_number }}" >> $GITHUB_STEP_SUMMARY
echo "Is the \"terms-of-services\" field present?" >> $GITHUB_STEP_SUMMARY
echo $PARSED_DATA >> $GITHUB_STEP_SUMMARY
fi
exit 1
plugin-not-accepted:
runs-on: ubuntu-latest
needs: parse-issue
if: always() && needs.parse-issue.outputs.accepted == 'false' # 没有同意服务
steps:
- uses: actions/checkout@v3
- name: Render template
id: render
uses: chuhlomin/render-template@v1.6
with:
template: .github/workflows/templates/plugin-not-accepted.md
vars: |
user: ${{ github.event.issue.user.login}}
- name: Add comment
if: env.ACT == false
uses: peter-evans/create-or-update-comment@v3.0.2
with:
comment-id: ${{ needs.react-to-new-issue.outputs.comment-id }}
edit-mode: replace
issue-number: ${{ github.event.issue.number }}
body: ${{ steps.render.outputs.result }}
# - name: Remove 'plugin/accepted' label
# if: env.ACT == false && contains(github.event.issue.labels.*.name, 'plugin/accepted')
# 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: ["plugin/accepted"]
# })
- name: Add 'plugin/not-accepted' label
if: env.ACT == false && !contains(github.event.issue.labels.*.name, 'plugin/not-accepted')
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: ["plugin/not-accepted"]
})
# plugin-accepted:
# runs-on: ubuntu-latest
# needs: [ react-to-new-issue, parse-issue ]
# if: failure() == false && needs.parse-issue.outputs.accepted == 'true' && !contains(github.event.issue.labels.*.name, 'plugin/accepted')
# steps:
# - uses: actions/checkout@v3
# - name: Render template
# id: render
# uses: chuhlomin/render-template@v1.6
# with:
# template: .github/workflows/templates/plugin-accepted.md
# vars: |
# user: ${{ github.event.issue.user.login}}
# - name: Add comment
# if: env.ACT == false
# uses: peter-evans/create-or-update-comment@v2
# with:
# comment-id: ${{ needs.react-to-new-issue.outputs.comment-id }}
# edit-mode: replace
# issue-number: ${{ github.event.issue.number }}
# body: ${{ steps.render.outputs.result }}
# - name: Remove 'plugin/not-accepted' label
# if: env.ACT == false && contains(github.event.issue.labels.*.name, 'plugin/not-accepted')
# 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: ["plugin/not-accepted"]
# })
# - name: Add 'plugin/accepted' label
# if: env.ACT == 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: ["plugin/accepted"]
# })
# plugin-not-found:
# runs-on: ubuntu-latest
# needs: [ react-to-new-issue, parse-issue ]
# if: always() && needs.parse-issue.outputs.accepted == 'null'
# steps:
# - uses: actions/checkout@v3
# - name: Render template when tos are not found
# id: render
# uses: chuhlomin/render-template@v1.6
# with:
# template: .github/workflows/templates/plugin-not-found.md
# - name: Add comment if tos not found
# if: env.ACT == false
# uses: peter-evans/create-or-update-comment@v2
# with:
# comment-id: ${{ needs.react-to-new-issue.outputs.comment-id }}
# edit-mode: replace
# issue-number: ${{ github.event.issue.number }}
# body: ${{ steps.render.outputs.result }}
# - name: Mark job as failed
# run: exit 1
validate:
name: plugin validation
needs: parse-issue
if: always() && needs.parse-issue.outputs.accepted == 'true'
uses: ./.github/workflows/validation.yaml