Created a first draft of this action. #14

Merged
Philipp merged 68 commits from draft into main 2023-11-19 23:21:49 +01:00
803 changed files with 54131 additions and 0 deletions
Showing only changes of commit 83d6ebd22a - Show all commits

View File

@ -16,13 +16,27 @@ async function getAndPostPullRequests() {
core.getInput("repo") || process.env.GITHUB_REPOSITORY.split("/")[1]; core.getInput("repo") || process.env.GITHUB_REPOSITORY.split("/")[1];
core.info(`Repository Name: ${repo}`); core.info(`Repository Name: ${repo}`);
const branch = core.getInput("branch");
const base_branch = core.getInput("base_branch") || "main"; 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} .`); 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)}`); // core.info(`Post Data: ${JSON.stringify(postData)}`);
const githubToken = core.getInput("github_token");
core.info("GitHub token retrieved."); core.info("GitHub token retrieved.");
// Headers with Authorization // Headers with Authorization
@ -56,7 +70,20 @@ async function getAndPostPullRequests() {
core.info( core.info(
`No open pulls found, to merge ${branch} into ${base_branch}. Trying to create a new PR.`, `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 // Perform the POST request
const postResponse = await fetch(url, { const postResponse = await fetch(url, {
method: "POST", method: "POST",