mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
* Ensure `github-token` wins for `git-cli` pushes * more shenanigans * Default to GitHub API commit mode * e2e auth tests * push missing utils * rename input * refactor * refactor * refactor * refactor * refactor * refactor * reuse helpers * refactor * refactor * simplify * add tests * refactor * improve comments * shift helper * add comments * extract test helpers * update docs and changesets * update one thing
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import * as core from "@actions/core";
|
|
import { GitHub } from "../github.ts";
|
|
import { runVersion } from "../run.ts";
|
|
import {
|
|
getOptionalInput,
|
|
getRequiredInput,
|
|
throwOnRemovedCommitModeInput,
|
|
validateChangesetsCliVersion,
|
|
} from "../utils.ts";
|
|
|
|
try {
|
|
await main();
|
|
} catch (err) {
|
|
core.setFailed((err as Error).message);
|
|
}
|
|
|
|
async function main() {
|
|
// If the user needs to change the cwd, set `working-directory` in the step instead
|
|
const cwd = process.cwd();
|
|
await validateChangesetsCliVersion(cwd);
|
|
throwOnRemovedCommitModeInput();
|
|
|
|
const githubToken = getRequiredInput("github-token");
|
|
const script = getOptionalInput("script");
|
|
const commitMessage = getRequiredInput("commit-message");
|
|
const prTitle = getRequiredInput("pr-title");
|
|
const prDraft = getOptionalInput("pr-draft");
|
|
const prBaseBranch = getOptionalInput("pr-base-branch");
|
|
const pushWithGitCli = core.getBooleanInput("push-with-git-cli");
|
|
|
|
// Validations
|
|
if (prDraft !== undefined && prDraft !== "always" && prDraft !== "create") {
|
|
throw new Error(`Invalid pr-draft input: ${prDraft}`);
|
|
}
|
|
const github = new GitHub({
|
|
cwd,
|
|
githubToken,
|
|
pushWithGitCli,
|
|
});
|
|
|
|
const { pullRequestNumber } = await runVersion({
|
|
script,
|
|
github,
|
|
cwd,
|
|
prTitle,
|
|
commitMessage,
|
|
// TODO: Use neutral message for PR description
|
|
hasPublishScript: true,
|
|
prDraft,
|
|
branch: prBaseBranch,
|
|
});
|
|
|
|
core.setOutput("pr-number", String(pullRequestNumber));
|
|
}
|