-
Notifications
You must be signed in to change notification settings - Fork 4
148 lines (130 loc) Β· 5.77 KB
/
process-created-issue.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
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
name: Process Created Issue
on:
issues:
types:
- opened
jobs:
issue-automation:
if: >-
${{
contains(github.event.issue.labels.*.name, 'kind/bug π') ||
contains(github.event.issue.labels.*.name, 'kind/docs π')
}}
runs-on: ubuntu-latest
env:
# Mimic ternary operator, see https://github.com/actions/runner/issues/409#issuecomment-752775072
TEMPLATE_TYPE: ${{ contains(github.event.issue.labels.*.name, 'kind/bug π') && 'bug' || 'docs' }}
TEMPLATE_VERSION: ${{ contains(github.event.issue.labels.*.name, 'Qv1') && 'v1' || 'v2' }}
steps:
- uses: actions/checkout@v2
- uses: stefanbuck/github-issue-parser@v2
id: issue-parser
with:
template-path: .github/ISSUE_TEMPLATE/${{ env.TEMPLATE_TYPE }}-report--bageldb-${{ env.TEMPLATE_VERSION }}.yml
- uses: actions/github-script@v5
env:
ISSUE_MODEL: ${{ steps.issue-parser.outputs.jsonString }}
INVALID_REPRO_MESSAGE: |
Hi @${{ github.event.issue.user.login }}! π
It looks like you provided an invalid or unsupported reproduction URL.
Do not use any service other than [Codepen](https://codepen.io), [jsFiddle](https://jsfiddle.net), [Codesandbox](https://codesandbox.io), and [GitHub](https://github.com).
Make sure the URL you provided is correct and reachable. You can test it by visiting it in a private tab, another device, etc.
Please **edit your original post above** and provide a valid reproduction URL as explained.
Without a proper reproduction, your issue will have to get closed.
Thank you for your collaboration. π
with:
script: |
const templateType = process.env.TEMPLATE_TYPE;
// Use it to differentiate the behavior between different template versions, if needed
// const templateVersion = process.env.TEMPLATE_VERSION;
const issueModel = JSON.parse(process.env.ISSUE_MODEL);
const labelsToAdd = [];
// Strip out the extra information like package names in between parantheses
const processValue = value => value.replace(/\s?\(.+\)$/, '');
if (issueModel.flavour) {
const flavourLabelMap = {
'BagelDB Flutter': 'flavour/bageldb-flutter',
'BagelDB JS': 'flavour/bageldb-js',
'BagelDB Nuxt': 'flavour/bageldb-nuxt',
'BagelDB Python': 'flavour/bageldb-python',
'BagelDB Swift': 'flavour/bageldb-swift',
'BagelDB Gatsby': 'flavour/gatsbyjs-source-plugin',
'BagelDB Gridsome Core': 'flavour/gatsbyjs-source-plugin',
'BagelDB Gridsome Pages': 'flavour/gatsbyjs-pages-plugin',
'BagelDB Vue Lazy Image': 'flavour/vue-bgl-image',
'BagelDB Client': 'flavour/client'
'BagelDB API/DOCS': 'flavour/docs'
};
const flavour = processValue(issueModel.flavour);
const flavourLabel = flavourLabelMap[flavour];
if (flavourLabel) {
labelsToAdd.push(flavourLabel);
}
}
if (issueModel.areas) {
const areasLabelMap = {
'Components': 'area/components'
'TypeScript Support': 'area/typescript'
'Content API': 'area/content-api'
'Content REST-API': 'arearest-api/'
'Meta API': 'area/meta-api'
'Bagel Auth API': 'area/bagel-auth'
'Bagel Auth REST-API': 'area/bagel-auth-rest'
};
const areaLabels = issueModel.areas
.split(', ')
.map(rawArea => {
const area = processValue(rawArea);
return areasLabelMap[area];
})
.filter(Boolean);
labelsToAdd.push(...areaLabels);
}
if (templateType === 'bug') {
try {
const reproURL = new URL(issueModel['repro-url']);
if (reproURL.protocol !== 'https:') {
throw Error();
}
switch(reproURL.hostname) {
case 'codepen.io':
if (/^\/.+\/(pen|project)\/.+$/.test(reproURL.pathname)) {
break;
}
case 'jsfiddle.net':
if (/^\/.+$/.test(reproURL.pathname)) {
break;
}
case 'codesandbox.io':
if (/^\/s\/.+$/.test(reproURL.pathname)) {
break;
}
case 'github.com':
if (/^\/.+\/.+$/.test(reproURL.pathname)) {
labelsToAdd.push('bug/1-hard-to-reproduce');
break;
}
default:
throw new Error();
}
labelsToAdd.push('bug/1-repro-available');
} catch {
labelsToAdd.push('bug/0-needs-info');
}
}
if (labelsToAdd.length > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: labelsToAdd
});
}
if (labelsToAdd.includes('bug/0-needs-info')) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: process.env.INVALID_REPRO_MESSAGE
});
}