mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a025e8ab1 | ||
|
|
3914e56b03 | ||
|
|
521c27bf86 | ||
|
|
2ccdaef0d0 | ||
|
|
26d7bf0c4b | ||
|
|
993a0a090d |
@@ -1,6 +1,6 @@
|
||||
name: Node CI
|
||||
|
||||
on: [push]
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# @changesets/action
|
||||
|
||||
## 1.3.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#167](https://github.com/changesets/action/pull/167) [`993a0a0`](https://github.com/changesets/action/commit/993a0a090df78cee07481d3886dcd8b29deb9567) Thanks [@dmregister](https://github.com/dmregister)! - Added `pullRequestNumber` to the action's outputs
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#157](https://github.com/changesets/action/pull/157) [`521c27b`](https://github.com/changesets/action/commit/521c27bf86ec53547d6a350d208fbbbc9d576fbc) Thanks [@emmenko](https://github.com/emmenko)! - Automatically adjust GitHub PR message if it exceeds a size limit of 60k characters by omitting some of the changelog information.
|
||||
|
||||
## 1.2.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -41,9 +41,6 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js 12.x
|
||||
uses: actions/setup-node@v2
|
||||
@@ -80,9 +77,6 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js 12.x
|
||||
uses: actions/setup-node@v2
|
||||
@@ -149,9 +143,6 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js 12.x
|
||||
uses: actions/setup-node@v2
|
||||
@@ -196,8 +187,6 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout Repo
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Node.js 12.x
|
||||
uses: actions/setup-node@v2
|
||||
|
||||
@@ -36,6 +36,8 @@ outputs:
|
||||
A JSON array to present the published packages. The format is `[{"name": "@xx/xx", "version": "1.2.0"}, {"name": "@xx/xy", "version": "0.8.9"}]`
|
||||
hasChangesets:
|
||||
description: A boolean about whether there were changesets. Useful if you want to create your own publishing functionality.
|
||||
pullRequestNumber:
|
||||
description: The pull request number that was created or updated
|
||||
branding:
|
||||
icon: "package"
|
||||
color: "blue"
|
||||
|
||||
Vendored
+921
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@changesets/action",
|
||||
"version": "1.2.2",
|
||||
"version": "1.3.0",
|
||||
"main": "dist/index.js",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
|
||||
@@ -6,6 +6,7 @@ Array [
|
||||
"base": "some-branch",
|
||||
"body": "This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to some-branch, this PR will be updated.
|
||||
|
||||
|
||||
# Releases
|
||||
## simple-project-pkg-a@1.1.0
|
||||
|
||||
@@ -18,7 +19,7 @@ Array [
|
||||
- Updated dependencies
|
||||
- simple-project-pkg-b@1.1.0
|
||||
|
||||
## simple-project-pkg-b@1.1.0
|
||||
## simple-project-pkg-b@1.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
@@ -32,12 +33,53 @@ Array [
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`version does not include any release information if a message with simplified release info exceeds size limit 1`] = `
|
||||
Array [
|
||||
Object {
|
||||
"base": "some-branch",
|
||||
"body": "This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to some-branch, this PR will be updated.
|
||||
|
||||
|
||||
# Releases
|
||||
|
||||
> All release information have been omitted from this message, as the content exceeds the size limit.",
|
||||
"head": "changeset-release/some-branch",
|
||||
"owner": "changesets",
|
||||
"repo": "action",
|
||||
"title": "Version Packages",
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`version does not include changelog entries if full message exceeds size limit 1`] = `
|
||||
Array [
|
||||
Object {
|
||||
"base": "some-branch",
|
||||
"body": "This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to some-branch, this PR will be updated.
|
||||
|
||||
|
||||
# Releases
|
||||
|
||||
> The changelog information of each package has been omitted from this message, as the content exceeds the size limit.
|
||||
|
||||
## simple-project-pkg-a@1.1.0
|
||||
|
||||
",
|
||||
"head": "changeset-release/some-branch",
|
||||
"owner": "changesets",
|
||||
"repo": "action",
|
||||
"title": "Version Packages",
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`version doesn't include ignored package that got a dependency update in the PR body 1`] = `
|
||||
Array [
|
||||
Object {
|
||||
"base": "some-branch",
|
||||
"body": "This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to some-branch, this PR will be updated.
|
||||
|
||||
|
||||
# Releases
|
||||
## ignored-package-pkg-b@1.1.0
|
||||
|
||||
@@ -59,6 +101,7 @@ Array [
|
||||
"base": "some-branch",
|
||||
"body": "This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to some-branch, this PR will be updated.
|
||||
|
||||
|
||||
# Releases
|
||||
## simple-project-pkg-a@1.1.0
|
||||
|
||||
|
||||
+4
-1
@@ -97,13 +97,16 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
|
||||
return;
|
||||
}
|
||||
case hasChangesets:
|
||||
await runVersion({
|
||||
const { pullRequestNumber } = await runVersion({
|
||||
script: getOptionalInput("version"),
|
||||
githubToken,
|
||||
prTitle: getOptionalInput("title"),
|
||||
commitMessage: getOptionalInput("commit"),
|
||||
hasPublishScript,
|
||||
});
|
||||
|
||||
core.setOutput("pullRequestNumber", String(pullRequestNumber));
|
||||
|
||||
return;
|
||||
}
|
||||
})().catch((err) => {
|
||||
|
||||
+130
@@ -57,6 +57,10 @@ describe("version", () => {
|
||||
() => ({ data: { items: [] } })
|
||||
);
|
||||
|
||||
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
|
||||
data: { number: 123 },
|
||||
}));
|
||||
|
||||
await writeChangesets(
|
||||
[
|
||||
{
|
||||
@@ -92,6 +96,10 @@ describe("version", () => {
|
||||
() => ({ data: { items: [] } })
|
||||
);
|
||||
|
||||
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
|
||||
data: { number: 123 },
|
||||
}));
|
||||
|
||||
await writeChangesets(
|
||||
[
|
||||
{
|
||||
@@ -123,6 +131,10 @@ describe("version", () => {
|
||||
() => ({ data: { items: [] } })
|
||||
);
|
||||
|
||||
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
|
||||
data: { number: 123 },
|
||||
}));
|
||||
|
||||
await writeChangesets(
|
||||
[
|
||||
{
|
||||
@@ -145,4 +157,122 @@ describe("version", () => {
|
||||
|
||||
expect(mockedGithubMethods.pulls.create.mock.calls[0]).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("does not include changelog entries if full message exceeds size limit", async () => {
|
||||
let cwd = f.copy("simple-project");
|
||||
linkNodeModules(cwd);
|
||||
|
||||
mockedGithubMethods.search.issuesAndPullRequests.mockImplementationOnce(
|
||||
() => ({ data: { items: [] } })
|
||||
);
|
||||
|
||||
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
|
||||
data: { number: 123 },
|
||||
}));
|
||||
|
||||
await writeChangesets(
|
||||
[
|
||||
{
|
||||
releases: [
|
||||
{
|
||||
name: "simple-project-pkg-a",
|
||||
type: "minor",
|
||||
},
|
||||
],
|
||||
summary: `# Non manus superum
|
||||
|
||||
## Nec cornibus aequa numinis multo onerosior adde
|
||||
|
||||
Lorem markdownum undas consumpserat malas, nec est lupus; memorant gentisque ab
|
||||
limine auctore. Eatque et promptu deficit, quam videtur aequa est **faciat**,
|
||||
locus. Potentia deus habebat pia quam qui coniuge frater, tibi habent fertque
|
||||
viribus. E et cognoscere arcus, lacus aut sic pro crimina fuit tum **auxilium**
|
||||
dictis, qua, in.
|
||||
|
||||
In modo. Nomen illa membra.
|
||||
|
||||
> Corpora gratissima parens montibus tum coeperat qua remulus caelum Helenamque?
|
||||
> Non poenae modulatur Amathunta in concita superi, procerum pariter rapto cornu
|
||||
> munera. Perrhaebum parvo manus contingere, morari, spes per totiens ut
|
||||
> dividite proculcat facit, visa.
|
||||
|
||||
Adspicit sequitur diffamatamque superi Phoebo qua quin lammina utque: per? Exit
|
||||
decus aut hac inpia, seducta mirantia extremo. Vidi pedes vetus. Saturnius
|
||||
fluminis divesque vulnere aquis parce lapsis rabie si visa fulmineis.
|
||||
`,
|
||||
},
|
||||
],
|
||||
cwd
|
||||
);
|
||||
|
||||
await runVersion({
|
||||
githubToken: "@@GITHUB_TOKEN",
|
||||
cwd,
|
||||
prBodyMaxCharacters: 1000,
|
||||
});
|
||||
|
||||
expect(mockedGithubMethods.pulls.create.mock.calls[0]).toMatchSnapshot();
|
||||
expect(mockedGithubMethods.pulls.create.mock.calls[0][0].body).toMatch(
|
||||
/The changelog information of each package has been omitted from this message/
|
||||
);
|
||||
});
|
||||
|
||||
it("does not include any release information if a message with simplified release info exceeds size limit", async () => {
|
||||
let cwd = f.copy("simple-project");
|
||||
linkNodeModules(cwd);
|
||||
|
||||
mockedGithubMethods.search.issuesAndPullRequests.mockImplementationOnce(
|
||||
() => ({ data: { items: [] } })
|
||||
);
|
||||
|
||||
mockedGithubMethods.pulls.create.mockImplementationOnce(() => ({
|
||||
data: { number: 123 },
|
||||
}));
|
||||
|
||||
await writeChangesets(
|
||||
[
|
||||
{
|
||||
releases: [
|
||||
{
|
||||
name: "simple-project-pkg-a",
|
||||
type: "minor",
|
||||
},
|
||||
],
|
||||
summary: `# Non manus superum
|
||||
|
||||
## Nec cornibus aequa numinis multo onerosior adde
|
||||
|
||||
Lorem markdownum undas consumpserat malas, nec est lupus; memorant gentisque ab
|
||||
limine auctore. Eatque et promptu deficit, quam videtur aequa est **faciat**,
|
||||
locus. Potentia deus habebat pia quam qui coniuge frater, tibi habent fertque
|
||||
viribus. E et cognoscere arcus, lacus aut sic pro crimina fuit tum **auxilium**
|
||||
dictis, qua, in.
|
||||
|
||||
In modo. Nomen illa membra.
|
||||
|
||||
> Corpora gratissima parens montibus tum coeperat qua remulus caelum Helenamque?
|
||||
> Non poenae modulatur Amathunta in concita superi, procerum pariter rapto cornu
|
||||
> munera. Perrhaebum parvo manus contingere, morari, spes per totiens ut
|
||||
> dividite proculcat facit, visa.
|
||||
|
||||
Adspicit sequitur diffamatamque superi Phoebo qua quin lammina utque: per? Exit
|
||||
decus aut hac inpia, seducta mirantia extremo. Vidi pedes vetus. Saturnius
|
||||
fluminis divesque vulnere aquis parce lapsis rabie si visa fulmineis.
|
||||
`,
|
||||
},
|
||||
],
|
||||
cwd
|
||||
);
|
||||
|
||||
await runVersion({
|
||||
githubToken: "@@GITHUB_TOKEN",
|
||||
cwd,
|
||||
prBodyMaxCharacters: 500,
|
||||
});
|
||||
|
||||
expect(mockedGithubMethods.pulls.create.mock.calls[0]).toMatchSnapshot();
|
||||
expect(mockedGithubMethods.pulls.create.mock.calls[0][0].body).toMatch(
|
||||
/All release information have been omitted from this message, as the content exceeds the size limit/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
+129
-57
@@ -4,6 +4,7 @@ import fs from "fs-extra";
|
||||
import { getPackages, Package } from "@manypkg/get-packages";
|
||||
import path from "path";
|
||||
import * as semver from "semver";
|
||||
import { PreState } from "@changesets/types";
|
||||
import {
|
||||
getChangelogEntry,
|
||||
execWithOutput,
|
||||
@@ -15,6 +16,12 @@ import * as gitUtils from "./gitUtils";
|
||||
import readChangesetState from "./readChangesetState";
|
||||
import resolveFrom from "resolve-from";
|
||||
|
||||
// GitHub Issues/PRs messages have a max size limit on the
|
||||
// message body payload.
|
||||
// `body is too long (maximum is 65536 characters)`.
|
||||
// To avoid that, we ensure to cap the message to 60k chars.
|
||||
const MAX_CHARACTERS_PER_MESSAGE = 60000;
|
||||
|
||||
const createRelease = async (
|
||||
octokit: ReturnType<typeof github.getOctokit>,
|
||||
{ pkg, tagName }: { pkg: Package; tagName: string }
|
||||
@@ -40,7 +47,7 @@ const createRelease = async (
|
||||
prerelease: pkg.packageJson.version.includes("-"),
|
||||
...github.context.repo,
|
||||
});
|
||||
} catch (err) {
|
||||
} catch (err: any) {
|
||||
// if we can't find a changelog, the user has probably disabled changelogs
|
||||
if (err.code !== "ENOENT") {
|
||||
throw err;
|
||||
@@ -158,7 +165,7 @@ export async function runPublish({
|
||||
const requireChangesetsCliPkgJson = (cwd: string) => {
|
||||
try {
|
||||
return require(resolveFrom(cwd, "@changesets/cli/package.json"));
|
||||
} catch (err) {
|
||||
} catch (err: any) {
|
||||
if (err && err.code === "MODULE_NOT_FOUND") {
|
||||
throw new Error(
|
||||
`Have you forgotten to install \`@changesets/cli\` in "${cwd}"?`
|
||||
@@ -168,6 +175,75 @@ const requireChangesetsCliPkgJson = (cwd: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
type GetMessageOptions = {
|
||||
hasPublishScript: boolean;
|
||||
branch: string;
|
||||
changedPackagesInfo: {
|
||||
highestLevel: number;
|
||||
private: boolean;
|
||||
content: string;
|
||||
header: string;
|
||||
}[];
|
||||
prBodyMaxCharacters: number;
|
||||
preState?: PreState;
|
||||
};
|
||||
|
||||
export async function getVersionPrBody({
|
||||
hasPublishScript,
|
||||
preState,
|
||||
changedPackagesInfo,
|
||||
prBodyMaxCharacters,
|
||||
branch,
|
||||
}: GetMessageOptions) {
|
||||
let messageHeader = `This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and ${
|
||||
hasPublishScript
|
||||
? `the packages will be published to npm automatically`
|
||||
: `publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing)`
|
||||
}. If you're not ready to do a release yet, that's fine, whenever you add more changesets to ${branch}, this PR will be updated.
|
||||
`;
|
||||
let messagePrestate = !!preState
|
||||
? `⚠️⚠️⚠️⚠️⚠️⚠️
|
||||
|
||||
\`${branch}\` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run \`changeset pre exit\` on \`${branch}\`.
|
||||
|
||||
⚠️⚠️⚠️⚠️⚠️⚠️
|
||||
`
|
||||
: "";
|
||||
let messageReleasesHeading = `# Releases`;
|
||||
|
||||
let fullMessage = [
|
||||
messageHeader,
|
||||
messagePrestate,
|
||||
messageReleasesHeading,
|
||||
...changedPackagesInfo.map((info) => `${info.header}\n\n${info.content}`),
|
||||
].join("\n");
|
||||
|
||||
// Check that the message does not exceed the size limit.
|
||||
// If not, omit the changelog entries of each package.
|
||||
if (fullMessage.length > prBodyMaxCharacters) {
|
||||
fullMessage = [
|
||||
messageHeader,
|
||||
messagePrestate,
|
||||
messageReleasesHeading,
|
||||
`\n> The changelog information of each package has been omitted from this message, as the content exceeds the size limit.\n`,
|
||||
...changedPackagesInfo.map((info) => `${info.header}\n\n`),
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
// Check (again) that the message is within the size limit.
|
||||
// If not, omit all release content this time.
|
||||
if (fullMessage.length > prBodyMaxCharacters) {
|
||||
fullMessage = [
|
||||
messageHeader,
|
||||
messagePrestate,
|
||||
messageReleasesHeading,
|
||||
`\n> All release information have been omitted from this message, as the content exceeds the size limit.`,
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
return fullMessage;
|
||||
}
|
||||
|
||||
type VersionOptions = {
|
||||
script?: string;
|
||||
githubToken: string;
|
||||
@@ -175,6 +251,11 @@ type VersionOptions = {
|
||||
prTitle?: string;
|
||||
commitMessage?: string;
|
||||
hasPublishScript?: boolean;
|
||||
prBodyMaxCharacters?: number;
|
||||
};
|
||||
|
||||
type RunVersionResult = {
|
||||
pullRequestNumber: number;
|
||||
};
|
||||
|
||||
export async function runVersion({
|
||||
@@ -184,7 +265,8 @@ export async function runVersion({
|
||||
prTitle = "Version Packages",
|
||||
commitMessage = "Version Packages",
|
||||
hasPublishScript = false,
|
||||
}: VersionOptions) {
|
||||
prBodyMaxCharacters = MAX_CHARACTERS_PER_MESSAGE,
|
||||
}: VersionOptions): Promise<RunVersionResult> {
|
||||
let repo = `${github.context.repo.owner}/${github.context.repo.repo}`;
|
||||
let branch = github.context.ref.replace("refs/heads/", "");
|
||||
let versionBranch = `changeset-release/${branch}`;
|
||||
@@ -214,55 +296,22 @@ export async function runVersion({
|
||||
q: searchQuery,
|
||||
});
|
||||
let changedPackages = await getChangedPackages(cwd, versionsByDirectory);
|
||||
let changedPackagesInfoPromises = Promise.all(
|
||||
changedPackages.map(async (pkg) => {
|
||||
let changelogContents = await fs.readFile(
|
||||
path.join(pkg.dir, "CHANGELOG.md"),
|
||||
"utf8"
|
||||
);
|
||||
|
||||
let prBodyPromise = (async () => {
|
||||
return (
|
||||
`This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and ${
|
||||
hasPublishScript
|
||||
? `the packages will be published to npm automatically`
|
||||
: `publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing)`
|
||||
}. If you're not ready to do a release yet, that's fine, whenever you add more changesets to ${branch}, this PR will be updated.
|
||||
${
|
||||
!!preState
|
||||
? `
|
||||
⚠️⚠️⚠️⚠️⚠️⚠️
|
||||
|
||||
\`${branch}\` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run \`changeset pre exit\` on \`${branch}\`.
|
||||
|
||||
⚠️⚠️⚠️⚠️⚠️⚠️
|
||||
`
|
||||
: ""
|
||||
}
|
||||
# Releases
|
||||
` +
|
||||
(
|
||||
await Promise.all(
|
||||
changedPackages.map(async (pkg) => {
|
||||
let changelogContents = await fs.readFile(
|
||||
path.join(pkg.dir, "CHANGELOG.md"),
|
||||
"utf8"
|
||||
);
|
||||
|
||||
let entry = getChangelogEntry(
|
||||
changelogContents,
|
||||
pkg.packageJson.version
|
||||
);
|
||||
return {
|
||||
highestLevel: entry.highestLevel,
|
||||
private: !!pkg.packageJson.private,
|
||||
content:
|
||||
`## ${pkg.packageJson.name}@${pkg.packageJson.version}\n\n` +
|
||||
entry.content,
|
||||
};
|
||||
})
|
||||
)
|
||||
)
|
||||
.filter((x) => x)
|
||||
.sort(sortTheThings)
|
||||
.map((x) => x.content)
|
||||
.join("\n ")
|
||||
);
|
||||
})();
|
||||
let entry = getChangelogEntry(changelogContents, pkg.packageJson.version);
|
||||
return {
|
||||
highestLevel: entry.highestLevel,
|
||||
private: !!pkg.packageJson.private,
|
||||
content: entry.content,
|
||||
header: `## ${pkg.packageJson.name}@${pkg.packageJson.version}`,
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
const finalPrTitle = `${prTitle}${!!preState ? ` (${preState.tag})` : ""}`;
|
||||
|
||||
@@ -278,22 +327,45 @@ ${
|
||||
|
||||
let searchResult = await searchResultPromise;
|
||||
console.log(JSON.stringify(searchResult.data, null, 2));
|
||||
|
||||
const changedPackagesInfo = (await changedPackagesInfoPromises)
|
||||
.filter((x) => x)
|
||||
.sort(sortTheThings);
|
||||
|
||||
let prBody = await getVersionPrBody({
|
||||
hasPublishScript,
|
||||
preState,
|
||||
branch,
|
||||
changedPackagesInfo,
|
||||
prBodyMaxCharacters,
|
||||
});
|
||||
|
||||
if (searchResult.data.items.length === 0) {
|
||||
console.log("creating pull request");
|
||||
await octokit.pulls.create({
|
||||
const { data: newPullRequest } = await octokit.pulls.create({
|
||||
base: branch,
|
||||
head: versionBranch,
|
||||
title: finalPrTitle,
|
||||
body: await prBodyPromise,
|
||||
body: prBody,
|
||||
...github.context.repo,
|
||||
});
|
||||
|
||||
return {
|
||||
pullRequestNumber: newPullRequest.number,
|
||||
};
|
||||
} else {
|
||||
octokit.pulls.update({
|
||||
pull_number: searchResult.data.items[0].number,
|
||||
const [pullRequest] = searchResult.data.items;
|
||||
|
||||
console.log(`updating found pull request #${pullRequest.number}`);
|
||||
await octokit.pulls.update({
|
||||
pull_number: pullRequest.number,
|
||||
title: finalPrTitle,
|
||||
body: await prBodyPromise,
|
||||
body: prBody,
|
||||
...github.context.repo,
|
||||
});
|
||||
console.log("pull request found");
|
||||
|
||||
return {
|
||||
pullRequestNumber: pullRequest.number,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user