Skip to content

Commit

Permalink
pull GITHUB_AUTH value from ISSUE_CREATOR_PAT environment variable so…
Browse files Browse the repository at this point in the history
… it will work with github environment variables as they can not start with github
  • Loading branch information
fostermh committed Jul 16, 2024
1 parent 1165273 commit bac0219
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions firebase-functions/functions/issue.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const { Octokit } = require("octokit");
const { Octokit, RequestError } = require("octokit");
const fs = require("fs");
const { defineString } = require('firebase-functions/params');

const githubAuth = defineString('GITHUB_AUTH');
const githubAuthCred = process.env.GITHUB_AUTH || githubAuth.value()
const githubAuth = defineString('GITHUB_AUTH') || defineString('ISSUE_CREATOR_PAT');
const githubAuthCred = process.env.GITHUB_AUTH || process.env.ISSUE_CREATOR_PAT || githubAuth.value()

function readIssueText(filename) {
try {
Expand All @@ -27,6 +27,22 @@ async function createIssue(title, url) {
body: `## ${title}\n\n<${url}>\n\n${issueText}`,
};

await octokit.request("POST /repos/{owner}/{repo}/issues", input);
try {
await octokit.request("POST /repos/{owner}/{repo}/issues", input);
} catch (error) {
// Octokit errors are instances of RequestError, so they always have an `error.status` property containing the HTTP response code.
if (error instanceof RequestError) {
// eslint-disable-next-line no-console
console.error(error);
// handle Octokit error
// error.message; // Oops
// error.status; // 500
// error.request; // { method, url, headers, body }
// error.response; // { url, status, headers, data }
} else {
// handle all other errors
throw error;
}
}
}
module.exports = createIssue;

0 comments on commit bac0219

Please sign in to comment.