Skip to content

Commit 120c6fa

Browse files
committed
Make github-pages transform respect --dry-run
1 parent 5253cd1 commit 120c6fa

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

transforms/github-pages.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,22 @@ module.exports = async function ({
2828

2929
source.branch = target;
3030

31-
await octokit.repos.updateInformationAboutPagesSite({
32-
owner,
33-
repo,
34-
source,
35-
});
31+
if (!dryRun) {
32+
await octokit.repos.updateInformationAboutPagesSite({
33+
owner,
34+
repo,
35+
source,
36+
});
37+
}
3638

3739
log(
3840
`Updated GitHub pages from [${old}] to [${target}] with path [${source.path}]`
3941
);
4042
} catch (e) {
41-
log(`No GitHub Pages found for [${owner}/${repo}]`);
43+
if (e.status === 404) {
44+
log(`No GitHub Pages found for [${owner}/${repo}]`);
45+
return;
46+
}
47+
throw e;
4248
}
4349
};

transforms/github-pages.test.js

+25
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,31 @@ describe("#github-pages", () => {
8383
);
8484
});
8585

86+
it("respects dryRun", async () => {
87+
nock("https://api.github.com/")
88+
.get("/repos/demo/repo/pages")
89+
.reply(200, {
90+
source: {
91+
branch: "master",
92+
path: "/",
93+
},
94+
});
95+
96+
await githubPages({
97+
owner: "demo",
98+
repo: "repo",
99+
old: "master",
100+
target: "main",
101+
octokit,
102+
log,
103+
dryRun: true,
104+
});
105+
106+
expect(log.logger).toBeCalledWith(
107+
"Updated GitHub pages from [master] to [main] with path [/]"
108+
);
109+
});
110+
86111
it("configures actions with the new branch (custom path)", async () => {
87112
nock("https://api.github.com/")
88113
.get("/repos/demo/repo/pages")

0 commit comments

Comments
 (0)