-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: base implementation for creating PRS
- Loading branch information
1 parent
049f470
commit 0104d82
Showing
4 changed files
with
98 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,42 @@ | ||
import core from "@actions/core"; | ||
import { getOctokit } from "@actions/github"; | ||
|
||
const srcBranch = core.getInput("src-branch"); | ||
function main() { | ||
const token = process.env.GITHUB_TOKEN; | ||
if (!token) { | ||
console.error("GITHUB_TOKEN not found"); | ||
return; | ||
} | ||
|
||
console.log(srcBranch); | ||
const octokit = getOctokit(token); | ||
|
||
const srcBranch = core.getInput("src-branch"); | ||
const targetBranch = core.getInput("target-branch"); | ||
|
||
if (!srcBranch || !targetBranch) { | ||
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({ | ||
owner, | ||
repo, | ||
title: `Merge changes from ${srcBranch} to ${targetBranch}`, | ||
head: srcBranch, | ||
base: targetBranch, | ||
body: "Automatically created pull request", | ||
}) | ||
.then((response) => { | ||
console.log(`Pull request created: ${response.data.html_url}`); | ||
}) | ||
.catch((error) => { | ||
console.error(`Error creating pull request: ${error.message}`); | ||
}); | ||
} | ||
|
||
main(); |