skohub-io / skohub-vocabs

A lightweight tool to publish SKOS Vocabularies
https://skohub.io/
Apache License 2.0
34 stars 25 forks source link

Set up automatic deployment to test #115

Closed acka47 closed 2 years ago

acka47 commented 3 years ago

For the development & review process with @literarymachine and @sroertgen as exernal partners, it would be nice to have a branch (test or dev) which gets automatically deployed when new commits are merged so that reviews can be done in a timely manner after fixes/features were added.

(The idea is, to reuse the for oerworldmap where only external people develop but hosting/deployment is done by @dr0i .)

It could be done with webhooks (see e.g. https://medium.com/better-programming/how-to-automatically-deploy-from-github-to-server-using-webhook-79f837dcc4f4) or GitHub Actions. (How do these things relate to another, anyway?)

dr0i commented 3 years ago

Main difference between GitHub Actions (https://www.cloudbooklet.com/setup-ci-cd-workflow-with-github-actions/) and a webhook is that for the latter you trigger something by making a web call (port 80/443) and the former you ssh-ing into the server using port 22 (or, for that matter, every port your sshd listens to). We have all ports closed to public except for web calls (80/443) so using ssh would be hard here (but not impossible) . Also, just a gut feeling - it feels safer to use a webhook than to to store ssh user and password at github for it to ssh-ing into one's server.

dr0i commented 3 years ago

Setup like this: anything pushed to branch dev in this repo will trigger a github webhook call. The webhook at the server calls this script:

#!/bin/bash

git fetch --all
git reset --hard origin/dev

PID=$(lsof -i:9006 | tail -n1 |cut -f5 -d " ")
kill $PID

and monit calls the start script, building and deploying and starting the daemon (you may have to wait a minute or so before the skohub-vocabs is up again - you will see this if you call e.g. https://test.skohub.io/dini-ag-kim/schulfaecher/heads/main/w3id.org/kim/schulfaecher/s1028.de.html - should be down immediately after pushing to dev and up again when redeployed).

This works so far, please test @acka47 . What's missing is the webhook under control of monit (so that the webhook listener will be restarted automatically if it should crash) - working on that.

dr0i commented 3 years ago

Webhook now under monit control :heavy_check_mark: .

acka47 commented 3 years ago

It looks like you broke something during the set up. Vocabs are now longer available – neither from within nor from without the hbz VPN. See e.g. https://skohub.io/dini-ag-kim/hcrt/heads/master/w3id.org/kim/hcrt/scheme

dr0i commented 3 years ago

Sorry, and thx! ... fixed it.

acka47 commented 3 years ago

We will test this when @sroertgen has added the adjustments in 127-index-all-prefLabels as announced in https://github.com/skohub-io/skohub-vocabs/pull/152#issuecomment-914102418. Is this ok for you, @dr0i?

dr0i commented 3 years ago

NP @acka47 :+1:

acka47 commented 2 years ago

This worked well with #156 . Thanks, @dr0i . Closing.