-
Notifications
You must be signed in to change notification settings - Fork 42
59 lines (54 loc) · 1.94 KB
/
validatenewrepo.yml
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
name: Validate New Plugin Repository
on:
issues:
types: [opened]
jobs:
run:
name: ValidateRepo
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Check Issue Label
id: check-label
uses: actions/github-script@v5
with:
script: |
const labels = context.payload.issue.labels;
const hasLabel = labels.some(label => label.name === 'new plugin');
if (!hasLabel) {
core.setOutput('skipRemainingSteps', 'true');
}
- name: Install dependencies
if: steps.check-label.outputs.skipRemainingSteps != 'true'
run: pip install -r requirements.txt
- name: Run Validator
if: steps.check-label.outputs.skipRemainingSteps != 'true'
run: python3 validate_json.py ${{ secrets.M_GITHUB_TOKEN }}
env:
ISSUE_CONTENT: ${{ github.event.issue.body }}
- name: Comment
if: (steps.check-label.outputs.skipRemainingSteps != 'true') && (failure())
uses: actions/github-script@v7
with:
script: |
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Sorry, this repository does not appear to have a valid plugin.json.
Please ensure it is valid JSON and that you have created an actual release.
`
})
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['invalid']
})
await github.rest.issues.update({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed'
})