Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle DOCUMENTER_KEY errors better in deploydocs #907

Merged
merged 3 commits into from
Dec 10, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@

* ![Enhancement][badge-enhancement] The default `documenter.sty` LaTeX preamble now include `\usepackage{graphicx}` ([#898][github-898]).

* ![Enhancement][badge-enhancement] `deploydocs` is now more helpful when it fails to interpret `DOCUMENTER_KEY`. It now also uses the `BatchMode` SSH option and throws an error instead of asking for a passphrase and timing out the Travis build when `DOCUMENTER_KEY` is broken. ([#697][github-697], [#907][github-907])

## Version `v0.20.0`

* Documenter v0.20 requires at least Julia v0.7. ([#795][github-795])
Expand Down Expand Up @@ -136,6 +138,7 @@

* ![Bugfix][badge-bugfix] At-docs blocks no longer give an error when containing empty lines. ([#823][github-823], [#824][github-824])

[github-697]: https://github.com/JuliaDocs/Documenter.jl/pull/697
[github-706]: https://github.com/JuliaDocs/Documenter.jl/pull/706
[github-764]: https://github.com/JuliaDocs/Documenter.jl/pull/764
[github-789]: https://github.com/JuliaDocs/Documenter.jl/pull/789
Expand All @@ -161,6 +164,7 @@
[github-885]: https://github.com/JuliaDocs/Documenter.jl/pull/885
[github-891]: https://github.com/JuliaDocs/Documenter.jl/pull/891
[github-898]: https://github.com/JuliaDocs/Documenter.jl/pull/898
[github-907]: https://github.com/JuliaDocs/Documenter.jl/pull/907


[badge-breaking]: https://img.shields.io/badge/BREAKING-red.svg
Expand Down
26 changes: 23 additions & 3 deletions src/Documenter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -547,13 +547,22 @@ function git_push(
dirname = isempty(dirname) ? temp : joinpath(temp, dirname)
isdir(dirname) || mkpath(dirname)

keyfile = abspath(joinpath(root, ".documenter"))
target_dir = abspath(target)

# The upstream URL to which we push new content and the ssh decryption commands.
upstream = "git@$(replace(repo, "github.com/" => "github.com:"))"

write(keyfile, String(base64decode(key)))
keyfile = abspath(joinpath(root, ".documenter"))
try
write(keyfile, String(base64decode(key)))
catch e
@error """
Documenter failed to decode the DOCUMENTER_KEY environment variable.
Make sure that the environment variable is properly set up as a Base64-encoded string
of the SSH private key. You may need to re-generate the keys with DocumenterTools.
"""
rethrow(e)
end
chmod(keyfile, 0o600)

try
Expand All @@ -564,6 +573,7 @@ function git_push(
StrictHostKeyChecking no
HostName github.com
IdentityFile $keyfile
BatchMode yes
"""
) do
cd(temp) do
Expand All @@ -574,7 +584,17 @@ function git_push(

# Fetch from remote and checkout the branch.
run(`git remote add upstream $upstream`)
run(`git fetch upstream`)
try
run(`git fetch upstream`)
catch e
@error """
Git failed to fetch $upstream
This can be caused by a DOCUMENTER_KEY variable that is not correctly set up.
Make sure that the environment variable is properly set up as a Base64-encoded string
of the SSH private key. You may need to re-generate the keys with DocumenterTools.
"""
rethrow(e)
end

try
run(`git checkout -b $branch upstream/$branch`)
Expand Down