From b85f32c0ee811b4637841ca5ec4c8de6d5c8bfd5 Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Mon, 10 Dec 2018 20:55:06 +1300 Subject: [PATCH] Handle DOCUMENTER_KEY errors better in deploydocs * Print a more helpful error if base64decode fails for the provided key. * Use SSH batch mode -- this means that SSH won't ask for passphrase and time out the Travis build if the SSH key is problematic. * Also, print a more helpful error if git fetch throws an error, most likely due to a key misconfiguration. Closes #697 --- src/Documenter.jl | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/Documenter.jl b/src/Documenter.jl index ce25209d18..bcaf20a11b 100644 --- a/src/Documenter.jl +++ b/src/Documenter.jl @@ -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 @@ -564,6 +573,7 @@ function git_push( StrictHostKeyChecking no HostName github.com IdentityFile $keyfile + BatchMode yes """ ) do cd(temp) do @@ -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`)