-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
164 lines (143 loc) · 6.38 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Process Created Issue
on:
issues:
types:
- opened
jobs:
issue-automation:
permissions:
contents: read # to fetch code (actions/checkout)
issues: write # to comment and add labels to issues
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@v4
- uses: stefanbuck/github-issue-parser@v3
id: issue-parser
with:
template-path: .github/ISSUE_TEMPLATE/${{ env.TEMPLATE_TYPE }}-report--quasar-${{ env.TEMPLATE_VERSION }}.yml
- uses: actions/github-script@v7
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), [StackBlitz](https://stackblitz.com), [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, e.g. 'Webpack-based Quasar CLI (@quasar/cli | @quasar/app-webpack)' -> 'Webpack-based Quasar CLI'
const processValue = value => value.replace(/\s?\(.+\)$/, '');
if (issueModel.flavour) {
const flavourLabelMap = {
'Quasar CLI with Vite': 'flavour/quasar-cli-vite',
'Quasar CLI with Webpack': 'flavour/quasar-cli-webpack',
'UMD': 'flavour/umd',
'Vite Plugin': 'flavour/vite-plugin',
'Vue CLI Plugin': 'flavour/vue-cli-plugin',
};
const flavour = processValue(issueModel.flavour);
const flavourLabel = flavourLabelMap[flavour];
if (flavourLabel) {
labelsToAdd.push(flavourLabel);
}
}
if (issueModel.areas) {
const areasLabelMap = {
'Quasar CLI Commands/Configuration': 'area/cli',
'Components': 'area/components',
'Directives': 'area/directives',
'Plugins': 'area/plugins',
'Composables': 'area/composables',
'Style & Identity': 'area/style',
'Accessibility [a11y]': 'area/a11y',
'Project Creation': 'area/project-creation',
'Quasar Extras': 'area/extras',
'TypeScript Support': 'area/typescript',
'App Extension API': 'area/app-ext',
'Icon Genie CLI': 'area/icongenie',
'SPA Mode': 'mode/spa',
'SSR Mode': 'mode/ssr',
'PWA Mode': 'mode/pwa',
'Electron Mode': 'mode/electron',
'Cordova Mode': 'mode/cordova',
'Capacitor Mode': 'mode/capacitor',
'BEX Mode': 'mode/bex',
};
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 'stackblitz.com':
if (/^\/edit\/.+$/.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
});
}