-
Notifications
You must be signed in to change notification settings - Fork 93
Description
New feature proposal:
For my own projects, I'm experimenting with 'deploy on commit'. The idea here is that the server that hosts the repository has both of
- Leiningen
- Babashka
and that the server that hosts the website, if different from the repo server, is set up to do SSH authentication by public key.
I am writing a Babashka post-receive git hook script that
- reads
content/config.edninto aconfigmap; - clones the repo into a configured staging directory (
:staging-dir); - runs
lein runin that repo; - on successful exit from
lein run, copies the contents of thepublicsub-directory to a configured deployment directory (:deploy-dir)- if the deployment directory string starts with
ssh:, usingscp; - otherwise, using
cp.
- if the deployment directory string starts with
The benefit for me is that I don't accidentally deploy the wrong project to the wrong server (this hasn't happened yet but is definitely a risk!), and for some of the projects I support which have multiple editors, that any editor can check out the project from the repo, add or amend a post, ideally run lein serve locally to check that everything looks right, push the project back to the repo, and everything will automatically deploy (modulo permissions having been set up properly).
I think this is useful functionality but it is also niche — I'm not sure how many Cryogen users would value it.
So I could either
- create you a pull request with both the post-receive hook and full documentation (when I have it working to my satisfaction), or
- simply write a blog post documenting how to do it.
It would obviously be possible for me to write the post-receive hook as a shell script rather than a babashka script, which would obviate the need to have babashka on the deployment server, if you would prefer that.
Finally, the script could try to automatically install leiningen on the server if it were not already installed, but although it would be technically possible this feels a little intrusive.