Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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