gis-ops / valhalla-app

This is the demo web app running on https://valhalla.openstreetmap.de
https://valhalla.openstreetmap.de
MIT License
163 stars 90 forks source link

Github Action to deploy #128

Closed nilsnolde closed 1 year ago

nilsnolde commented 1 year ago

What would you like to share?

Not sure yet how to do that very well (e.g. public key in the secrets?), but it'd be nicest if we had a Github Action which deploys the app on the global server.

aa98-45556443355666 commented 1 year ago

I want to work on the issue. Kindly assign it to me.

Ananya2001-an commented 1 year ago

We need to integrate the hosting platform with this repo as an environment. Like github pages or netlify does. Which platform are we using here to host the app?

nilsnolde commented 1 year ago

Ah sorry, missed this one..

We're not using fancy tools tbh, the built app is deployed to a dedicated machine at Hetzner. Gotta figure out how to integrate that with Actions. Worst case have the private key in Github secrets (if possible).

Ananya2001-an commented 1 year ago

Ah sorry, missed this one..

We're not using fancy tools tbh, the built app is deployed to a dedicated machine at Hetzner. Gotta figure out how to integrate that with Actions. Worst case have the private key in Github secrets (if possible).

Ah, okay. Never heard of Hetzner before. Will check it out 👍🏼

nilsnolde commented 1 year ago

It's just a cheaper alternative to AWS. You get VMs, dedicated machines etc, without all the useless bells & whistles of AWS. We got the latter for our Valhalla servers.

But honestly, this could even work with Github pages, custom domains aren't a problem. Custom subdomains don't seem to be a problem either, looking at it quickly. We can figure that out soon:) I do love Github Pages, I'd definitely prefer that over manual setup.

Ananya2001-an commented 1 year ago

Yeah I guess that would be nicer since implementing actions with it will be a breeze. Moreover, we can also add a rule for gh-pages deployments (preview) when someone raises a PR. This will make it easier to test the changes as well.

nilsnolde commented 1 year ago

Moreover, we can also add a rule for gh-pages deployments (preview) when someone raises a PR. This will make it easier to test the changes as well.

That’d be awesome! It’s really the major reason for review pain.

You’re sure that’s possible? I mean without overriding the live URL on our custom subdomain? I can’t see how that’s possible but very happy to be told otherwise:)

Ananya2001-an commented 1 year ago

Moreover, we can also add a rule for gh-pages deployments (preview) when someone raises a PR. This will make it easier to test the changes as well.

That’d be awesome! It’s really the major reason for review pain.

You’re sure that’s possible? I mean without overriding the live URL on our custom subdomain? I can’t see how that’s possible but very happy to be told otherwise:)

Yes it's possible. I am not sure about github pages because I never tried looking into it but with netlify it was automatically activated whenever someone raised a PR. It will generate a preview. There are also options for gitpod deployment preview which is also a great way to test changes since it will open the website preview along with new code changes in IDE.

Ananya2001-an commented 1 year ago

You can check out this PR: https://github.com/Ananya2001-an/githubwars/pull/27

nilsnolde commented 1 year ago

Ok that’d definitely be pretty cool. Let’s see if it’s possible with the combo of GitHub Pages & custom (own) sub-domain. It’d be the icing on the cake, even „just“ releasing the app via Actions on master pushes would be beautiful.

Ananya2001-an commented 1 year ago

Ok that’d definitely be pretty cool. Let’s see if it’s possible with the combo of GitHub Pages & custom (own) sub-domain. It’d be the icing on the cake, even „just“ releasing the app via Actions on master pushes would be beautiful.

Actually with GitHub pages as environment, we don’t even need an action. It will automatically start deploying the new changes on push to master branch.

nilsnolde commented 1 year ago

Jep that's true! Github made it really easy.

TLDR I asked the OSM admins if we can add a CName record to the valhalla.openstreetmap.de subdomain. But there's security concerns, see https://medium.com/@jehy/hijacking-domain-using-github-pages-41c80ac57523. It's unclear if those still persist, but it seems mildly dangerous. I didn't have the headspace to fully test the situation, though I did quickly did a test with one of our subdomains and https://github.com/gis-ops/routingjs, which worked. But even when I remove the CName record from our domain host, I could still access the Github Pages site. That's reason for concern, apparently Github still doesn't fact-check ownership of domains..

In the end Github Pages won't work our for us. I'd imagine a small app which we're in full control of, wouldn't be too hard:

Then we wouldn't just deploy on master pushes, but we could also see the built apps for PRs on https://subdomain.gis-ops.com/<PR_ID> which would be super helpful for reviewing.

I realize this is what actual services can do already like netlify or even partly Github Pages. But this could be really just 2 days of work and would help us in all web dev related projects, private or public.

nilsnolde commented 1 year ago

Or maybe someone here knows a small OSS project which does that already? A quick search wasn't successful..

nilsnolde commented 1 year ago

Could also be a nice little "palate cleanser" for the GSoC project:) Though no worries, I wouldn't expect a GSoC student to complete this within 2 days;)

Ananya2001-an commented 1 year ago

Jep that's true! Github made it really easy.

TLDR I asked the OSM admins if we can add a CName record to the valhalla.openstreetmap.de subdomain. But there's security concerns, see https://medium.com/@jehy/hijacking-domain-using-github-pages-41c80ac57523. It's unclear if those still persist, but it seems mildly dangerous. I didn't have the headspace to fully test the situation, though I did quickly did a test with one of our subdomains and https://github.com/gis-ops/routingjs, which worked. But even when I remove the CName record from our domain host, I could still access the Github Pages site. That's reason for concern, apparently Github still doesn't fact-check ownership of domains..

That's horrible!

In the end Github Pages won't work our for us. I'd imagine a small app which we're in full control of, wouldn't be too hard:

  • set up a Github webhook for master pushes & PR pushes
  • small server app (Python pls;)) listening for the webhook(s), checks the secret token, parses the payload and npm run builds the branch which was pushed to, and copies the artifacts to a subdirectory which is served on a subdomain; the server would need a bit of configuration, e.g. where to copy master and PRs distributions to, in our case that'll be different domains
  • built dists should also be deleted again for PRs when they're closed, but that's just another tiny endpoint
  • the rest is some apache/nginx configuration

Then we wouldn't just deploy on master pushes, but we could also see the built apps for PRs on https://subdomain.gis-ops.com/<PR_ID> which would be super helpful for reviewing.

I realize this is what actual services can do already like netlify or even partly Github Pages. But this could be really just 2 days of work and would help us in all web dev related projects, private or public.

That sounds good 👍🏼

Ananya2001-an commented 1 year ago

Or maybe someone here knows a small OSS project which does that already? A quick search wasn't successful..

ChatGPT might also help, not sure.

hs7898753 commented 1 year ago

Jep that's true! Github made it really easy.

TLDR I asked the OSM admins if we can add a CName record to the valhalla.openstreetmap.de subdomain. But there's security concerns, see https://medium.com/@jehy/hijacking-domain-using-github-pages-41c80ac57523. It's unclear if those still persist, but it seems mildly dangerous. I didn't have the headspace to fully test the situation, though I did quickly did a test with one of our subdomains and https://github.com/gis-ops/routingjs, which worked. But even when I remove the CName record from our domain host, I could still access the Github Pages site. That's reason for concern, apparently Github still doesn't fact-check ownership of domains..

In the end Github Pages won't work our for us. I'd imagine a small app which we're in full control of, wouldn't be too hard:

  • set up a Github webhook for master pushes & PR pushes
  • small server app (Python pls;)) listening for the webhook(s), checks the secret token, parses the payload and npm run builds the branch which was pushed to, and copies the artifacts to a subdirectory which is served on a subdomain; the server would need a bit of configuration, e.g. where to copy master and PRs distributions to, in our case that'll be different domains
  • built dists should also be deleted again for PRs when they're closed, but that's just another tiny endpoint
  • the rest is some apache/nginx configuration

Then we wouldn't just deploy on master pushes, but we could also see the built apps for PRs on https://subdomain.gis-ops.com/<PR_ID> which would be super helpful for reviewing.

I realize this is what actual services can do already like netlify or even partly Github Pages. But this could be really just 2 days of work and would help us in all web dev related projects, private or public.

Look interesting.

hs7898753 commented 1 year ago

@Ananya2001-an Are you working on this issue or May I try?

nilsnolde commented 1 year ago

Tbh, I'd not consider this a good project for an applicant, but thanks for the offer. It's smth we can consider once we start for real end of May. It'll be a separate repo in the gis-ops org, so it needs pretty close mentoring to be max useful to our company and still allow enough room for customization since it'll be OSS. Prio for our use cases for sure.

hs7898753 commented 1 year ago

okay! actually, I really got excited about this issue

nilsnolde commented 1 year ago

Feel free to start your own implementation anytime, if you want:) If you do, a liberal license would be appreciated.

hs7898753 commented 1 year ago

Thanks, I will try it whenever I get time

hs7898753 commented 1 year ago

Or maybe someone here knows a small OSS project which does that already? A quick search wasn't successful..

@nilsnolde https://github.com/logsol/Github-Auto-Deploy Is it what we are expecting?

nilsnolde commented 1 year ago

Yeah right, smth like that I had in mind! Thanks for digging that up!

Yesterday we actually quickly tested a possible GitHub Actions flow for deploying the app on prod & also to review PRs. That worked really easy:)

We’ll publish PR deployments on this URL: https://valhalla-app-tests.gis-ops.com. It’s still protected but next week we’ll open that.

hs7898753 commented 1 year ago

@nilsnolde We can also include Health check or Rollback functionality like features. health check feature can help us to know about some errors in the deployment. In case a new deployment causes issues, rollback feature have the ability to quickly roll back to the previous working deployment. I think it can be very helpful.