mirror of
https://github.com/anuraghazra/github-readme-stats.git
synced 2025-01-30 14:08:14 +08:00
infra: getPrNumber fix (#357)
This commit is contained in:
parent
7a4b0930fc
commit
792e5a4ba7
@ -3,21 +3,25 @@ const github = require("@actions/github");
|
||||
const parse = require("parse-diff");
|
||||
require("dotenv").config();
|
||||
|
||||
const parsePullRequestId = (githubRef) => {
|
||||
const result = /refs\/pull\/(\d+)\/merge/g.exec(githubRef);
|
||||
if (!result) {
|
||||
console.log("Reference not found.");
|
||||
return 297;
|
||||
function getPrNumber() {
|
||||
const pullRequest = github.context.payload.pull_request;
|
||||
if (!pullRequest) {
|
||||
return undefined;
|
||||
}
|
||||
const [, pullRequestId] = result;
|
||||
return pullRequestId;
|
||||
};
|
||||
|
||||
return pullRequest.number;
|
||||
}
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
const token = core.getInput("token");
|
||||
const octokit = github.getOctokit(token || process.env.PERSONAL_TOKEN);
|
||||
const pullRequestId = parsePullRequestId(process.env.GITHUB_REF);
|
||||
const pullRequestId = getPrNumber();
|
||||
|
||||
if (!pullRequestId) {
|
||||
console.log("PR not found");
|
||||
return;
|
||||
}
|
||||
|
||||
let res = await octokit.pulls.get({
|
||||
owner: "anuraghazra",
|
||||
|
Loading…
Reference in New Issue
Block a user