-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (118 loc) · 4.2 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
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: 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"]
})
validate:
name: plugin validation
needs: parse-issue
if: always() && needs.parse-issue.outputs.accepted == 'true'
uses: ./.github/workflows/validation.yaml