generated from actions/container-toolkit-action
-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.ts
34 lines (30 loc) · 1.09 KB
/
main.ts
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
import * as core from '@actions/core'
import * as github from '@actions/github'
import {getIssueLabels} from './functions'
const {getRepoLabels, addLabels} = require('./github')
export async function run() {
try {
console.log('*** running renato66/auto-label version 2.1.2 ***')
const token = core.getInput('repo-token', {required: true})
const client = new github.GitHub(token)
const issue = github.context.payload.issue
if (issue === undefined) {
throw new Error('Issue undefined')
}
console.log('Getting repository labels...')
const repoLabels: string = await getRepoLabels(client)
console.log(`Repository labels found: ${repoLabels.length}`)
console.log('Reading labels in issue...')
const issueLabels: string[] = getIssueLabels(issue.body, repoLabels)
console.log(`Labels found: ${issueLabels.length}`)
if (issueLabels.length !== 0) {
console.log('Adding labels to issue...')
await addLabels(client, issue.number, issueLabels)
}
console.log('Done')
} catch (error) {
core.setFailed(error.message)
throw error
}
}
run()