This repository has been archived by the owner on Sep 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
issues.js
56 lines (48 loc) · 1.68 KB
/
issues.js
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
const fs = require('fs')
const { Octokit } = require("@octokit/rest");
const octokit = new Octokit({
auth: process.env.GH_KEY
})
const fetchContents = fs.readFileSync('./templates/fetch.md', 'utf8');
const parseContents = fs.readFileSync('./templates/parse.md', 'utf8');
const normalizeContents = fs.readFileSync('./templates/normalize.md', 'utf8');
const user = process.env.GH_USER
const repo = process.env.REPO
async function createFetchIssue(runnerPath, url) {
console.log(`Creating fetch issue for ${runnerPath}...`)
const issue = await octokit.rest.issues.create({
owner: user,
repo: repo,
title: `fetch ${runnerPath}`,
body: fetchContents.replace(/\[url\]/g, url).replace(/\[runnerPath\]/g, runnerPath),
labels: ['runner/fetch']
})
return issue.data.number
}
async function createParseIssue(runnerPath, blockedBy) {
console.log(`Creating parse issue for ${runnerPath}...`)
const issue = await octokit.rest.issues.create({
owner: user,
repo: repo,
title: `parse ${runnerPath}`,
body: parseContents.replace(/\[runnerPath\]/g, runnerPath).replace(/\[issueNumber\]/g, blockedBy),
labels: ['runner/parse']
})
return issue.data.number
}
async function createNormalizeIssue(runnerPath, blockedBy) {
console.log(`Creating normalize issue for ${runnerPath}...`)
const issue = await octokit.rest.issues.create({
owner: user,
repo: repo,
title: `normalize ${runnerPath}`,
body: normalizeContents.replace(/\[runnerPath\]/g, runnerPath).replace(/\[issueNumber\]/g, blockedBy),
labels: ['runner/normalize']
})
return issue.data.number
}
module.exports = {
createFetchIssue: createFetchIssue,
createParseIssue: createParseIssue,
createNormalizeIssue: createNormalizeIssue
}