I initially thought that the plugin paginate-v2 would not work with my site because it is hosted on GitHub but i just read this in the documentation:
GitHub Pages cannot build sites using unsupported plugins. If you want to use unsupported plugins, generate your site locally and then push your site’s static files to GitHub.
But that’s how I always update my website. By doing some local changes on a new branch, pushing the new one up to GitHub and then merging to master with the GitHub UI. Does this mean this plugin will work for me? Can someone explain this step by step for me?
No it will not work. It only works when you put your _site directory on GitHub. GitHub is unable to transform your Markdown into HTML since you are using paginate-v2.
Wow okay. I guess i need to abandon Jekyll then cause i’m at a loss of moving forward. I need certain features in the new plugin that the basic one just can’t do (like paginate sorted posts). But i can’t use the new plugin so I guess i need a new static website generator.
@jhvanderschee So it looks like I can build it locally and then just push that up to the remote master branch on github. As per the second comment here, the person says:
You can still host static files on Github Pages, you just can’t use Github Pages to build the site with most plugins. Do the build on your local computer and push the contents of _site to your gh-pages branch.
That seems reasonable. I just test it all locally. Build it all locally prior to merging my branch and that’s it. One extra setup but still doable…
Thanks @mmistakes that is a relief. I will look into Github actions. If you know any online tutorials / blog posts off the top of your head, please feel free to post it.
I have template with instructions here. What’s great about this is that the flow is generic so you can switch you build steps to make a React app and it will work.
I also have another template which uses a more opinionated flow. It is focused on Jekyll and it does a lot in one external Action so it is less flexible
I made that as part of a tutorial i wrote on the Jekyll docs website
I have links on a few tools here. I link to a lot of resources I wrote on GH Actions including some Jekyll sections in Cookbook.
There is a Netlify section too. Netlify needs a config of a few lines and it will install dependencies for you, plus it has some other features GH Actions lacks. So consider using Netlify.
Thans @MichaelCurrin I will try to set this up and let you know if I run into any issues. For setting up an access token on Github, do set an expiry date to that or just let it go forever (which is not recommended).
GitHub Actions actually generates a token for you on each run and it is scoped to only work in that repo. It might even auto expire. But you never have to view or copy the token
so it is super secure
Note that is the flow in the generic template I shared.
There is no manual generation and no choice for expiration so I recommend this one.
Another option is to generate a token manually for your user (yes for all your repos and you can’t scope it one repo). And then add that to secrets for a repo. I avoid this option if possible because it is less secure. But some Actions only work with this approach, so just check the docs of an action to see what it supports.
And yes if you generate a token manually you have the optionally to expire it or set no expiry time. If you are using the token for GH Actions, then you only view and copy the token once and never have to look at it again and also GH will mask it from the logs even if the value is printed (it shows as *****).
so it is safe enough to not expire for most cases. or you expire it and have to remember to regenerate and update it every 90 days or whatever manually.
It is more worth expiring a token if you are not using GH Actions and you leave the security of GitHub behind. For example, I download GH API data using a manually generated token that i put in a config file on my machine or I put it on a server like on Amazon or Netlify. Then I run Python or Ruby to get data from the API and use it for a report or whatever. There is more a of a risk of the token being viewed by someone with access to the system or for the token to be printed in the logs and someone steals it, because it is outside of GH. (Well Netlify will mask the token fortunately)
So basically if you do need to generate a token manually but you add it to GH secrets and then want to never touch it for a few years but know it is secure, I’d say no expiration is fine. I mean the expiration only came out as a feature in the last few months and didn’t exist for years before that, so it’s not like it’s essential for everyone otherwise no one would use those tokens in the past.
@MichaelCurrin That’s super interesting. Thank you for all the information. Yes i think i will def try your first option where the token is auto-generated for me at build time so it’s simpler.
@MichaelCurrin I’ve setup my github action yml file with the online interface, essentially following this tutorial: _drafts | Deploy a Jekyll Site with GitHub Actions (v2)
Everything seems to be okay on Github, it has a checkmark and when i ran it manually it seemed to be good.
My question now is how do i go about merging a new feature on another branch? Do i just merge to master and hope it builds correctly? Is there a way to do a final build test before I merge to master? How can rollback quickly in case it messes up?
Thanks @MichaelCurrin . So i’ve opened a pull request of my new feature which involves a plugin that is not supported natively by Github (paginate-v2) and the GH action is telling me that the build is failing, but i don’t know why:
@MichaelCurrin Thanks for your help. I have edited my deploy script but the same error persists, here is the bundle install line expanded:
/opt/hostedtoolcache/Ruby/2.6.1/x64/bin/bundle config --local path /home/runner/work/giving-tuesday.github.io/giving-tuesday.github.io/vendor/bundle
/opt/hostedtoolcache/Ruby/2.6.1/x64/bin/bundle config --local deployment true
Cache key: setup-ruby-bundler-cache-v3-ubuntu-20.04-ruby-2.6.1-Gemfile.lock-8686bf8910cd2da82c2923b2d4cd899b57e98db6d5fca137f27912705a841667
Received 39185761 of 39185761 (100.0%), 39.1 MBs/sec
Cache Size: ~37 MB (39185761 B)
/usr/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/a738583c-98f2-4a3d-a435-6303258c49e0/cache.tzst -P -C /home/runner/work/giving-tuesday.github.io/giving-tuesday.github.io
Cache restored successfully
Found cache for key: setup-ruby-bundler-cache-v3-ubuntu-20.04-ruby-2.6.1-Gemfile.lock-190933042ff06c476312da164e440e0f02542c1784479db6edb6ade87da9e270
/opt/hostedtoolcache/Ruby/2.6.1/x64/bin/bundle install --jobs 4
Your bundle only supports platforms ["x86_64-darwin-20"] but your local platform
is x86_64-linux. Add the current platform to the lockfile with `bundle lock
--add-platform x86_64-linux` and try again.
Took 2.50 seconds
Error: The process '/opt/hostedtoolcache/Ruby/2.6.1/x64/bin/bundle' failed with exit code 16
And here is my new deploy script:
name: build site with jekyll and deploy on github pages
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
jekyll:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
- name: Set up Ruby 💎
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6.1 # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Build 🏗
run: bundle exec jekyll build --trace
# use actions-gh-pages to deploy
# https://github.com/peaceiris/actions-gh-pages
- name: Deploy to GH Pages 🚀
uses: peaceiris/actions-gh-pages@v3
with:
# GITHUB_TOKEN secret is set up automatically
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./_site