Skip to content

Commit

Permalink
update build
Browse files Browse the repository at this point in the history
  • Loading branch information
mshick committed Nov 5, 2022
1 parent 3bebc58 commit 7238e87
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ const core = __importStar(require("@actions/core"));
const github = __importStar(require("@actions/github"));
const http_client_1 = require("@actions/http-client");
const promises_1 = __importDefault(require("node:fs/promises"));
const listCommitPulls = async (params) => {
const { repoToken, owner, repo, commitSha } = params;
const http = new http_client_1.HttpClient('http-client-add-pr-comment');
const additionalHeaders = {
accept: 'application/vnd.github.groot-preview+json',
authorization: `token ${repoToken}`,
};
const body = await http.getJson(`https://api.github.com/repos/${owner}/${repo}/commits/${commitSha}/pulls`, additionalHeaders);
return body.result;
};
const getIssueNumberFromCommitPullsList = (commitPullsList) => (commitPullsList.length ? commitPullsList[0].number : null);
const createCommentProxy = async (params) => {
const { repoToken, owner, repo, issueNumber, body, proxyUrl } = params;
Expand Down Expand Up @@ -99,6 +89,7 @@ const run = async () => {
return;
}
const [owner, repo] = repoFullName.split('/');
const octokit = github.getOctokit(repoToken);
let issueNumber;
if (issue && issue.number) {
issueNumber = issue.number;
Expand All @@ -108,15 +99,18 @@ const run = async () => {
}
else {
// If this is not a pull request, attempt to find a PR matching the sha
const commitPullsList = await listCommitPulls({ repoToken, owner, repo, commitSha });
issueNumber = commitPullsList && getIssueNumberFromCommitPullsList(commitPullsList);
const commitPullsList = await octokit.rest.repos.listPullRequestsAssociatedWithCommit({
owner,
repo,
commit_sha: commitSha,
});
issueNumber = commitPullsList.data && getIssueNumberFromCommitPullsList(commitPullsList.data);
}
if (!issueNumber) {
core.info('this action only works on issues and pull_request events or other commits associated with a pull');
core.setOutput('comment-created', 'false');
return;
}
const octokit = github.getOctokit(repoToken);
let shouldCreateComment = true;
if (!allowRepeats) {
core.debug('repeat comments are disallowed, checking for existing');
Expand Down

0 comments on commit 7238e87

Please sign in to comment.