Created
April 29, 2016 08:43
-
-
Save simonbyrne/c22830777a15957e153c220904248f40 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setup(pkgname) | |
Pkg.cd() do | |
cd(pkgname) do | |
info("Generating ssh key") | |
run(`ssh-keygen -N "" -f .quickdocs_id_rsa`) | |
info("Encrypting private key") | |
run(`travis login --auto`) | |
run(`travis encrypt-file .quickdocs_id_rsa --add deploy`) | |
info("Removing unencrypted ssh private key") | |
rm(".quickdocs_id_rsa") | |
info("Appending lines to .travis.yml") | |
info("Posting deploy key to GitHub") | |
url = Pkg.Git.readchomp(`config remote.origin.url`) | |
m = match(Pkg.Git.GITHUB_REGEX, url) | |
m === nothing && error("Not a GitHub repo, cannot post deploy key.") | |
owner, repo = m.captures[2:3] | |
status, response = Pkg.GitHub.POST("repos/$owner/$repo/keys", | |
Dict(:title => "QuickDocs.jl", | |
:key => open(readchomp,".quickdocs_id_rsa.pub"), | |
:read_only => false)) | |
status == 201 || error("deploying public key to $owner/$repo failed: $(response["message"])") | |
info("Initialising GitHub Pages") | |
initial_sha = readchomp(`git rev-list --max-parents=0 HEAD`) | |
status, response = Pkg.GitHub.POST("repos/$owner/$repo/git/refs", | |
Dict(:ref => "refs/heads/gh-pages", | |
:sha => readchomp(`git rev-list --max-parents=0 HEAD`))) | |
status == 201 || error("Initialising $owner/$repo gh-pages branch failed: $(response["message"])") | |
info("Success!") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment