fixed-an-action (#20)
Some checks failed
Auto Maintenance Cycle / pre-commit Autoupdate (push) Failing after 31s
Some checks failed
Auto Maintenance Cycle / pre-commit Autoupdate (push) Failing after 31s
Reworked the action to include an pass for the 409 error. Reviewed-on: #20 Co-authored-by: Philipp Horstenkamp <philipp@horstenkamp.de> Co-committed-by: Philipp Horstenkamp <philipp@horstenkamp.de>
This commit is contained in:
13
index.js
13
index.js
@ -2,8 +2,6 @@ const core = require("@actions/core");
|
||||
|
||||
async function getAndPostPullRequests() {
|
||||
try {
|
||||
core.info("Starting the action...");
|
||||
|
||||
// Retrieve inputs and token
|
||||
const baseUrl = core.getInput("base_url") || "https://git.horstenkamp.eu";
|
||||
const owner = core.getInput("owner") || process.env.GITHUB_REPOSITORY_OWNER;
|
||||
@ -36,11 +34,11 @@ async function getAndPostPullRequests() {
|
||||
// Prepare POST data
|
||||
const postData = {
|
||||
title: title,
|
||||
body: body,
|
||||
body: body ? body : undefined,
|
||||
head: branch,
|
||||
base: base_branch,
|
||||
assignees: assigneesInput ? assigneesInput.split(",") : [],
|
||||
reviewers: reviewersInput ? reviewersInput.split(",") : [],
|
||||
assignees: assigneesInput ? assigneesInput.split(",") : undefined,
|
||||
reviewers: reviewersInput ? reviewersInput.split(",") : undefined,
|
||||
due_date: dueDate || undefined,
|
||||
milestone: milestone ? parseInt(milestone, 10) : 0,
|
||||
};
|
||||
@ -53,7 +51,10 @@ async function getAndPostPullRequests() {
|
||||
headers,
|
||||
body: JSON.stringify(postData),
|
||||
});
|
||||
|
||||
if (postResponse.status === 409) {
|
||||
core.warning("PR between the branches already exists.");
|
||||
return;
|
||||
}
|
||||
if (!postResponse.ok) {
|
||||
throw new Error(
|
||||
`HTTP error! status on creating a new PR: ${postResponse.status}`,
|
||||
|
Reference in New Issue
Block a user