timwis / jkan

A lightweight, backend-free open data portal, powered by Jekyll
https://jkan.io
MIT License
218 stars 310 forks source link

Use GitHub Actions to deploy to GitHub Pages #238

Closed timwis closed 1 year ago

timwis commented 1 year ago

Per #199, this uses the latest approach to deploying to GitHub Pages (for users who will still prefer to use GitHub Pages over Netlify).

This is based on GitHub's starter workflow for deploying jekyll sites to GitHub Pages

I've got it passing a couple env vars for the github-metadata gem, and the correct branch so that the editor works properly, but the "Edit on GitHub" link is still broken if the fork uses a different default branch from the upstream (an issue with the github-metadata gem).

The main thing I still need to figure out is how to get it to work with user/org pages (instead of repo) pages. For some reason it still gets deployed to <org-name>.github.io/org-name instead of just <org-name>.github.io.

To test:

  1. Fork the jkan repo to your own account (user or org), and make sure to untick the box that says "only copy the gh-pages branch"
  2. Go to your repo's settings > Pages > switch Source from "deploy from a branch" to "GitHub Actions"
  3. Go to this pull request's branch and modify .github.workflows/github-pages.yml, changing the branch on L12 from gh-pages to the name of this branch (github-actions-deploy-pages)
  4. That should automatically kick off a deployment, but if not, go to the Actions page, select this specific action, and there's a button on the right to manually deploy it.

Note that if you want to test editing functionality you'll need to point it to an oauth server per the readme.

timwis commented 1 year ago

Oh, turns out the org repo was working. I was just naming the repo <org-name> when I should have been naming it <org-name>.github.io. Doh!

So then this PR is ready for review. Once it's merged, I'll enable it on the main JKAN repo, which should make it enabled by default for future forks.

timwis commented 1 year ago

Thanks for testing. Hopefully once I add the branch to the environments tab on this repo, it won't be necessary to do so on forks 🤞🏻