-
Notifications
You must be signed in to change notification settings - Fork 45
158 lines (134 loc) · 6.41 KB
/
issue-validation.yml
File metadata and controls
158 lines (134 loc) · 6.41 KB
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
name: Validate Issue
on:
issues:
types: [opened]
jobs:
process-issue:
if: contains(join(github.event.issue.labels.*.name, ','), 'bug') || contains(join(github.event.issue.labels.*.name, ','), 'doc')
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v2
- name: View the GitHub context
run: echo "$GITHUB_CONTEXT"
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
- name: Set labels in a global environment variable
id: set_labels
run: echo "LABELS=${{ join(github.event.issue.labels.*.name, ',') }}" >> $GITHUB_ENV
- uses: stefanbuck/github-issue-parser@v3
if: contains(env.LABELS, 'bug')
id: issue-parser
- run: cat ${HOME}/issue-parser-result.json
if: contains(env.LABELS, 'bug')
- name: Extract issue details
if: contains(env.LABELS, 'bug')
id: extract
run: |
echo "Extracting issue details..."
echo "Processing as a bug report..."
reproduction_url=$(echo $REPRODUCTION_URL || echo "Not defined")
themes=$(echo $THEMES || echo "")
themes_short_forms=$(echo "${THEMES}" | sed 's/Not sure//; s/All/theme: All/; s/Bundesministerium der Finanzen/theme: BMF/; s/Default/theme: Default/; s/European Comission/theme: EC/; s/European Union/theme: EU/; s/Informationstechnikzentrum Bund/theme: ITZ/; s/Unstyled/theme: Unstyled/' | sed 's/^,*//;s/,*$//')
IFS=',' read -r -a themes_array <<< "$themes_short_forms"
for theme in "${themes_array[@]}"; do
theme_no_spaces="${theme// /}"
echo "THEME_LABEL_$theme_no_spaces=$theme_no_spaces" >> $GITHUB_ENV
done
error_category=$(echo $CATEGORY || echo "Not defined")
browser_info=$(echo $BROWSER || echo "Not defined")
reproduction=$(echo $REPRODUCTION || echo "Not defined")
expacted_behavior=$(echo $EXPACTED_BEHAVIOR || echo "Not defined")
components=$(echo $COMPONENTS || echo "")
components_label=$(echo "${components}" | sed 's/\n/,/g' | sed 's/^,*//;s/,*$//' || echo "")
IFS=',' read -r -a components_array <<< "$components_label"
for component in "${components_array[@]}"; do
component_no_spaces="${component// /}"
echo "COMPONENT_LABEL_$component_no_spaces=$component_no_spaces" >> $GITHUB_ENV
done
system_info=$(echo $SYSTEM || echo "Not defined")
kolibri_version=$(echo "$system_info" | grep -oP '"@public-ui/components": "\K[^"]+' | sed 's/[^0-9.]//g' || echo "N/A")
kolibri_major_version=$(echo "$kolibri_version" | cut -d '.' -f 1)
kolibri_version_label="v$kolibri_major_version"
echo "KOLIBRI_VERSION_LABEL=$kolibri_version_label" >> $GITHUB_ENV
NEW_ISSUE_BODY=$(cat <<EOF
### Link to the code that reproduces this issue:
$reproduction_url
### Can you categorise where the error occurs?
$error_category
### Which browser or operating system do you used to test KoliBri?
$browser_info
### How to reproduce issue?
$reproduction
### Current vs. Expected:
$expacted_behavior
### Environment informations:
$system_info
EOF
)
echo "NEW_ISSUE_BODY<<EOF" >> $GITHUB_ENV
echo "$NEW_ISSUE_BODY" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
env:
REPRODUCTION_URL: ${{ steps.issue-parser.outputs.issueparser_link_to_the_code_that_reproduces_this_issue }}
THEMES: ${{ steps.issue-parser.outputs.issueparser_which_themes_are_affected }}
CATEGORY: ${{ steps.issue-parser.outputs.issueparser_can_you_categorise_where_the_error_occurs_if_known }}
BROWSER: ${{ steps.issue-parser.outputs.issueparser_which_browser_or_operating_system_do_you_used_to_test_kolibri_if_available }}
COMPONENTS: ${{ steps.issue-parser.outputs.issueparser_which_componentareas_are_affected_select_all_that_apply }}
REPRODUCTION: ${{ steps.issue-parser.outputs.issueparser_to_reproduce }}
EXPACTED_BEHAVIOR: ${{ steps.issue-parser.outputs.issueparser_current_vs_expected_behavior }}
SYSTEM: ${{ steps.issue-parser.outputs.issueparser_provide_environment_information }}
- name: Check if user is a team member
id: check-team
uses: actions/github-script@v7
with:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
script: |
try {
const result = await github.rest.teams.getMembershipForUserInOrg({
org: context.repo.owner,
team_slug: 'specteam',
username: context.payload.sender.login
});
if (result.data.state === 'active') {
core.setOutput('team_member', 'true');
} else {
core.setOutput('team_member', 'false');
}
} catch (error) {
core.error(`${error}`);
core.setOutput('team_member', 'false');
}
return
- name: Update issue
uses: actions/github-script@v7
with:
script: |
const labelsToAdd = ['${{ env.LABELS }}'];
const isBug = labelsToAdd.includes('bug');
if ('${{ steps.check-team.outputs.team_member }}' === 'true') {
labelsToAdd.push('created-by: kolibri-team');
}
if (isBug == true) {
if ('${{ env.KOLIBRI_VERSION_LABEL }}') {
labelsToAdd.push('${{ env.KOLIBRI_VERSION_LABEL }}');
}
for (const key of Object.keys(process.env)) {
if ((key.startsWith('THEME_LABEL_') || key.startsWith('COMPONENT_LABEL_')) && process.env[key]) {
labelsToAdd.push(process.env[key]);
}
}
core.info(`Labels to add: ${labelsToAdd.join(', ')}`);
await github.rest.issues.update({
...context.repo,
issue_number: context.issue.number,
body: process.env.NEW_ISSUE_BODY,
labels: labelsToAdd
});
} else {
await github.rest.issues.update({
...context.repo,
issue_number: context.issue.number,
labels: labelsToAdd
});
}