cryogen-project / cryogen-project/cryogen
Deploy on commit?
- Dominant language
- HTML
- Stars
- 1.1k
- Forks
- 93
- PR merge metrics
- No merged PRs in 30d
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
1. Leiningen
2. 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
1. reads `content/config.edn` into a `config` map;
2. clones the repo into a configured staging directory (`:staging-dir`);
3. runs `lein run` in that repo;
4. on successful exit from `lein run`, copies the contents of the `public` sub-directory to a configured deployment directory (`:deploy-dir`)
1. if the deployment directory string starts with `ssh:`, using `scp`;
2. otherwise, using `cp`.
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
1. create you a pull request with both the post-receive hook and full documentation (when I have it working to my satisfaction), or
2. 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.
Contributor guide
Assessment
This issue has not been assessed yet.