Added a few arguments.
Some checks failed
Auto Maintenance Cycle / pre-commit Autoupdate (push) Failing after 31s

This commit is contained in:
Philipp Horstenkamp 2023-11-19 14:35:26 +01:00
parent 0f232d312e
commit 83d6ebd22a
Signed by: Philipp
GPG Key ID: DD53EAC36AFB61B4

View File

@ -16,13 +16,27 @@ async function getAndPostPullRequests() {
core.getInput("repo") || process.env.GITHUB_REPOSITORY.split("/")[1];
core.info(`Repository Name: ${repo}`);
const branch = core.getInput("branch");
const base_branch = core.getInput("base_branch") || "main";
const assigneesInput = core.getInput("assignees");
const reviewersInput = core.getInput("reviewers");
const labelsInput = core.getInput("labels");
const githubToken = core.getInput("github_token");
const branch = core.getInput("branch");
if (!branch) {
const ref = process.env.GITHUB_REF;
if (ref && ref.startsWith("refs/heads/")) {
branch = ref.replace("refs/heads/", "");
}
}
core.info(`The branch ${branch} should be merged into ${base_branch} .`);
if (!body) {
core.warning("Warning: PR body is empty.");
}
// core.info(`Post Data: ${JSON.stringify(postData)}`);
const githubToken = core.getInput("github_token");
core.info("GitHub token retrieved.");
// Headers with Authorization
@ -56,7 +70,20 @@ async function getAndPostPullRequests() {
core.info(
`No open pulls found, to merge ${branch} into ${base_branch}. Trying to create a new PR.`,
);
return { message: "Abort for thesting" };
// return { message: "Abort for thesting" };
// Perform the POST request
// Prepare POST data
const postData = {
title: title,
body: body,
head: branch,
base: base_branch,
};
if (assigneesInput) postData.assignees = assigneesInput.split(",");
if (reviewersInput) postData.reviewers = reviewersInput.split(",");
if (labelsInput) postData.labels = labelsInput.split(",");
// Perform the POST request
const postResponse = await fetch(url, {
method: "POST",