Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: read git acount info from env #16

Merged
merged 1 commit into from
May 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ export async function bumpWorkspaces(
parseCommitMessage = defaultParseCommitMessage,
start,
base,
gitUserName = "denobot",
gitUserEmail = "[email protected]",
gitUserName,
gitUserEmail,
githubToken,
githubRepo,
dryRun = false,
Expand Down Expand Up @@ -197,6 +197,27 @@ export async function bumpWorkspaces(
);

if (dryRun === false) {
gitUserName ??= Deno.env.get("GIT_USER_NAME");
if (gitUserName === undefined) {
console.error("GIT_USER_NAME is not set.");
Deno.exit(1);
}
gitUserEmail ??= Deno.env.get("GIT_USER_EMAIL");
if (gitUserEmail === undefined) {
console.error("GIT_USER_EMAIL is not set.");
Deno.exit(1);
}
githubToken ??= Deno.env.get("GITHUB_TOKEN");
if (githubToken === undefined) {
console.error("GITHUB_TOKEN is not set.");
Deno.exit(1);
}
githubRepo ??= Deno.env.get("GITHUB_REPOSITORY");
if (githubRepo === undefined) {
console.error("GITHUB_REPOSITORY is not set.");
Deno.exit(1);
}

// Makes a commit
console.log(
`Creating a git commit in the new branch ${magenta(newBranchName)}.`,
Expand All @@ -210,17 +231,7 @@ export async function bumpWorkspaces(

// Makes a PR
console.log(`Creating a pull request.`);
githubToken ??= Deno.env.get("GITHUB_TOKEN");
if (githubToken === undefined) {
console.error("GITHUB_TOKEN is not set.");
Deno.exit(1);
}
const octoKit = new Octokit({ auth: githubToken });
githubRepo ??= Deno.env.get("GITHUB_REPOSITORY");
if (githubRepo === undefined) {
console.error("GITHUB_REPOSITORY is not set.");
Deno.exit(1);
}
const [owner, repo] = githubRepo.split("/");
const openedPr = await octoKit.request(
"POST /repos/{owner}/{repo}/pulls",
Expand Down
Loading