Skip to content

Commit 2446813

Browse files
committed
don't require branch to exist
1 parent f3d8fd3 commit 2446813

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

docs/make.jl

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,15 @@ MultiDocumenter.make(
4040

4141
gitroot = normpath(joinpath(@__DIR__, ".."))
4242
run(`git pull`)
43-
# we expect gh-pages to already be set up
44-
run(`git checkout gh-pages`)
43+
outbranch = "gh-pages"
44+
has_outbranch = true
45+
if !success(`git checkout $outbranch`)
46+
has_outbranch = false
47+
if !success(`git switch --orphan $outbranch`)
48+
@error "Cannot create new orphaned branch $outbranch."
49+
exit(1)
50+
end
51+
end
4552
for file in readdir(gitroot; join = true)
4653
endswith(file, ".git") && continue
4754
rm(file; force = true, recursive = true)
@@ -50,6 +57,14 @@ for file in readdir(outpath)
5057
cp(joinpath(outpath, file), joinpath(gitroot, file))
5158
end
5259
run(`git add .`)
53-
run(`git commit -m 'Aggregate documentation'`)
54-
run(`git push`)
55-
run(`git checkout main`)
60+
if success(`git commit -m 'Aggregate documentation'`)
61+
@info "Pushing updated documentation."
62+
if has_outbranch
63+
run(`git push`)
64+
else
65+
run(`git push -u origin $outbranch`)
66+
end
67+
run(`git checkout main`)
68+
else
69+
@info "No changes to aggregated documentation."
70+
end

0 commit comments

Comments
 (0)