Skip to content

Commit

Permalink
Merge pull request #1797 from intuit/gh-pages-dry-run-bug
Browse files Browse the repository at this point in the history
Do not execute gh-pages build during a dry run
  • Loading branch information
hipstersmoothie committed Feb 11, 2021
2 parents 8202af4 + 21d8fad commit 5416946
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 22 deletions.
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

0 comments on commit 5416946

Please sign in to comment.