GH automation: Add missing user-agent header for GitHub api (#9338)

Fixes https://github.com/fleetdm/fleet/pull/9336
This commit is contained in:
Mike McNeil
2023-01-14 17:25:37 -06:00
committed by GitHub
parent 7b65368920
commit bc874cdd1d
+5 -1
View File
@@ -197,6 +197,10 @@ module.exports = {
let repo = repository.name;
let issueNumber = issueOrPr.number;
let newBotComment;
let baseHeadersForGithubApiRequests = {
'User-Agent': 'Fleetie pie',
'Authorization': `token ${sails.config.custom.githubAccessToken}`
};
if (!sails.config.custom.openAiSecret) {
throw new Error('sails.config.custom.openAiSecret not set. Cannot respond with haiku.');
@@ -219,7 +223,7 @@ module.exports = {
// Now that we know what to say, add our comment.
await sails.helpers.http.post('https://api.github.com/repos/'+encodeURIComponent(owner)+'/'+encodeURIComponent(repo)+'/issues/'+encodeURIComponent(issueNumber)+'/comments',
{'body': newBotComment},
{'Authorization': 'token '+sails.config.custom.githubAccessToken}
baseHeadersForGithubApiRequests
);
} else if (