diff --git a/dist/index.js b/dist/index.js index 93de2f5..a8e05ce 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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(); diff --git a/src/index.ts b/src/index.ts index 36a4e0d..c04f935 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import { getInput } from "@actions/core"; +import { getInput, setFailed, debug } from "@actions/core"; import { getOctokit, context } from "@actions/github"; function main() { @@ -16,20 +16,24 @@ function main() { const { repo, owner } = context.repo; + const createParam: Parameters[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}`); }); }