Skip to content

Commit

Permalink
fix: bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bonyuta0204 committed Nov 29, 2023
1 parent af5f214 commit bdd8de6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
14 changes: 7 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30814,23 +30814,23 @@ function main() {
console.error("Source or target branch not specified");
return;
}
// Assuming the context of the action has repository information
const owner = process.env.GITHUB_REPOSITORY_OWNER || "";
const repo = (process.env.GITHUB_REPOSITORY || "").split("/")[1];
octokit.rest.pulls
.create({
const { repo, owner } = github_1.context.repo;
const createParam = {
owner,
repo,
title: `Merge changes from ${srcBranch} to ${targetBranch}`,
head: srcBranch,
base: targetBranch,
body: "Automatically created pull request",
})
};
(0, core_1.debug)(`Creating pull request: ${JSON.stringify(createParam)}`);
octokit.rest.pulls
.create(createParam)
.then((response) => {
console.log(`Pull request created: ${response.data.html_url}`);
})
.catch((error) => {
console.error(`Error creating pull request: ${error.message}`);
(0, core_1.setFailed)(`Error creating pull request: ${error.message}`);
});
}
main();
Expand Down
24 changes: 14 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getInput } from "@actions/core";
import { getInput, setFailed, debug } from "@actions/core";
import { getOctokit, context } from "@actions/github";

function main() {
Expand All @@ -16,20 +16,24 @@ function main() {

const { repo, owner } = context.repo;

const createParam: Parameters<typeof octokit.rest.pulls.create>[0] = {
owner,
repo,
title: `Merge changes from ${srcBranch} to ${targetBranch}`,
head: srcBranch,
base: targetBranch,
body: "Automatically created pull request",
};

debug(`Creating pull request: ${JSON.stringify(createParam)}`);

octokit.rest.pulls
.create({
owner,
repo,
title: `Merge changes from ${srcBranch} to ${targetBranch}`,
head: srcBranch,
base: targetBranch,
body: "Automatically created pull request",
})
.create(createParam)
.then((response) => {
console.log(`Pull request created: ${response.data.html_url}`);
})
.catch((error) => {
console.error(`Error creating pull request: ${error.message}`);
setFailed(`Error creating pull request: ${error.message}`);
});
}

Expand Down

0 comments on commit bdd8de6

Please sign in to comment.