Skip to content

Commit

Permalink
Make github-pages transform respect --dry-run
Browse files Browse the repository at this point in the history
  • Loading branch information
mheap committed Dec 28, 2020
1 parent 5253cd1 commit 120c6fa
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
18 changes: 12 additions & 6 deletions transforms/github-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,22 @@ module.exports = async function ({

source.branch = target;

await octokit.repos.updateInformationAboutPagesSite({
owner,
repo,
source,
});
if (!dryRun) {
await octokit.repos.updateInformationAboutPagesSite({
owner,
repo,
source,
});
}

log(
`Updated GitHub pages from [${old}] to [${target}] with path [${source.path}]`
);
} catch (e) {
log(`No GitHub Pages found for [${owner}/${repo}]`);
if (e.status === 404) {
log(`No GitHub Pages found for [${owner}/${repo}]`);
return;
}
throw e;
}
};
25 changes: 25 additions & 0 deletions transforms/github-pages.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,31 @@ describe("#github-pages", () => {
);
});

it("respects dryRun", async () => {
nock("https://api.github.com/")
.get("/repos/demo/repo/pages")
.reply(200, {
source: {
branch: "master",
path: "/",
},
});

await githubPages({
owner: "demo",
repo: "repo",
old: "master",
target: "main",
octokit,
log,
dryRun: true,
});

expect(log.logger).toBeCalledWith(
"Updated GitHub pages from [master] to [main] with path [/]"
);
});

it("configures actions with the new branch (custom path)", async () => {
nock("https://api.github.com/")
.get("/repos/demo/repo/pages")
Expand Down

0 comments on commit 120c6fa

Please sign in to comment.