Repository navigation
57 lines (53 loc) · 2.12 KB
/
Copy pathlabel-language.yml
File metadata and controls
57 lines (53 loc) · 2.12 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
name: Label by language and add to project
on:
issues:
types: [opened]
jobs:
triage:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/github-script@v7
with:
github-token: ${{ secrets.PROJECT_TOKEN }}
script: |
const body = context.payload.issue.body || '';
// --- language label ---
const langMatch = body.match(/### Language\s*\n+([^\n]+)/);
if (langMatch) {
const langMap = {
'Deutsch - German (de)': 'lang: German',
'Español - Spanish (es)': 'lang: Spanish',
'Français - French (fr)': 'lang: French',
'Italiano - Italian (it)': 'lang: Italian',
'한국어 - Korean (ko)': 'lang: Korean',
'Português - Portuguese (pt)': 'lang: Portuguese',
'Русский - Russian (ru)': 'lang: Russian',
'ไทย - Thai (th)': 'lang: Thai',
'中文 - Chinese Simplified (zh_Hans)': 'lang: Chinese Simplified',
};
const label = langMap[langMatch[1].trim()];
if (label) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.issue.number,
labels: [label],
});
}
}
// --- add to org project #8 ---
const { organization } = await github.graphql(`
query { organization(login: "massif-press") { projectV2(number: 8) { id } } }
`);
await github.graphql(`
mutation($project: ID!, $issue: ID!) {
addProjectV2ItemById(input: { projectId: $project, contentId: $issue }) {
item { id }
}
}
`, {
project: organization.projectV2.id,
issue: context.payload.issue.node_id,
});