Skip to content

Instantly share code, notes, and snippets.

@efueyo
Last active June 7, 2018 11:50
Show Gist options
  • Select an option

  • Save efueyo/56ff086dd2693c4b27443b362704da9f to your computer and use it in GitHub Desktop.

Select an option

Save efueyo/56ff086dd2693c4b27443b362704da9f to your computer and use it in GitHub Desktop.
Download Titles from Github Repo Issues
const Promise = require('bluebird')
const fs = require('fs')
const octokit = require('@octokit/rest')()
octokit.authenticate({
type: 'basic',
username: 'USER',
password: 'PASS',
})
function handleGithubResponse(response, filename) {
const data = response.data
data.filter(
issue => !issue.pull_request
).forEach(
issue => fs.appendFileSync(`${filename}`, `${issue.title}\n`)
)
}
async function getIssueTitles({owner, repo, filename}) {
let response = await octokit.issues.getForRepo({
owner, repo, per_page: 100, state: 'all'
})
handleGithubResponse(response, filename)
while (octokit.hasNextPage(response)) {
response = await octokit.getNextPage(response)
handleGithubResponse(response, filename)
}
}
const repos = [
{
owner: 'facebook',
repo: 'react',
filename: 'react-issues.txt',
}, {
owner: 'vuejs',
repo: 'vue',
filename: 'vue-issues.txt',
}, {
owner: 'angular',
repo: 'angular',
filename: 'angular-issues.txt',
},
]
Promise.mapSeries(repos, getIssueTitles)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment