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

Do not execute gh-pages build during a dry run #1797

Merged
merged 1 commit into from Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions plugins/gh-pages/__tests__/gh-pages.test.ts
Expand Up @@ -45,6 +45,14 @@ describe("Gh-Pages Plugin", () => {
expect(execSpy).not.toHaveBeenCalled();
});

test("should not release on anything on a dry run", async () => {
const hooks = createTest({ dir: "test" });

await hooks.beforeShipIt.promise({ releaseType: "latest", dryRun: true });

expect(execSpy).not.toHaveBeenCalled();
});

test("should not release if there is a version bump", async () => {
const hooks = createTest({ dir: "test" }, { getVersion: () => "patch" });

Expand Down
47 changes: 25 additions & 22 deletions plugins/gh-pages/src/index.ts
Expand Up @@ -53,35 +53,38 @@ export default class GhPagesPlugin implements IPlugin {
}
});

auto.hooks.beforeShipIt.tapPromise(this.name, async ({ releaseType }) => {
if (releaseType !== "latest" || !auto.git) {
return;
}
auto.hooks.beforeShipIt.tapPromise(
this.name,
async ({ releaseType, dryRun }) => {
if (releaseType !== "latest" || !auto.git || dryRun) {
return;
}

const bump = await auto.getVersion();
const bump = await auto.getVersion();

// If it's a bump the 'afterRelease' hook will release the docs
if (bump !== SEMVER.noVersion) {
return;
}
// If it's a bump the 'afterRelease' hook will release the docs
if (bump !== SEMVER.noVersion) {
return;
}

const sha = await auto.git.getSha();
const pr = await auto.git.matchCommitToPr(sha);
const sha = await auto.git.getSha();
const pr = await auto.git.matchCommitToPr(sha);

if (!pr) {
return;
}
if (!pr) {
return;
}

const hasDocumentationLabel = pr.labels.includes(this.options.label);
const hasDocumentationLabel = pr.labels.includes(this.options.label);

if (!hasDocumentationLabel) {
return;
}
if (!hasDocumentationLabel) {
return;
}

// If: skip-release + w/documentation label then we will push to gh-pages
await auto.setGitUser();
await this.releaseGhPages(auto);
});
// If: skip-release + w/documentation label then we will push to gh-pages
await auto.setGitUser();
await this.releaseGhPages(auto);
}
);

auto.hooks.afterRelease.tapPromise(this.name, async ({ response }) => {
if (!response) {
Expand Down