I am making a bot that can grab a source.zip / source.targz from Github, then implement it into my app and new changes are applied, but I have not found a way to download a release because the @Octokit/Rest module I'm using only gets the release. Not download. Other npm packages don't work for me and if so, the node_modules folder can get really big, around 19mb. When I do a https GET request, Github requires me to use a USERAGENT, but I don't know how to tie in Octokit with plain HTTPS requests.
I want to be able to download releases by code, but what I get is the following in the zipfile I tie it to:
Request forbidden by administrative rules. Please make sure your request has a User-Agent header (http://developer.github.com/v3/#user-agent-required). Check https://developer.github.com for other possible causes.
var file = fs.createWriteStream('bot.zip')
var request = await https.get(releases[num].zipball_url, function(response) {
response.pipe(file)
})
//https://stackoverflow.com/questions/11944932/how-to-download-a-file-with-node-js-without-using-third-party-libraries
var octokit = new Octokit.Octokit({
userAgent: 'Github Bot Updater',
previews: ['jean-grey', 'symmetra'],
baseUrl: 'https://api.github.com',
log: {
debug: () => {},
info: () => {},
warn: console.warn,
error: console.error
},
request: {
agent: undefined,
fetch: undefined,
timeout: 0
}
})
var releases = await octokit.paginate("GET /repos/:owner/:repo/releases", { owner: username, repo: reponame})
//octokit has no method for downloading a release