Set up GitHub Pages compatibility with new Gemfile and scripts

- Updated Gemfile for GitHub Pages compatibility, including necessary gems.
- Added Gemfile.github-pages for specific GitHub Pages dependencies.
- Created scripts to switch between GitHub Pages and local development setups.
- Introduced GitHub Actions workflow for building and deploying the Jekyll site to GitHub Pages.
This commit is contained in:
Z. Cliffe Schreuders
2025-09-15 23:33:11 +01:00
parent 3d9029a200
commit 94d4f3b74a
5 changed files with 129 additions and 3 deletions

60
.github/workflows/jekyll.yml vendored Normal file
View File

@@ -0,0 +1,60 @@
name: Build and deploy Jekyll site to GitHub Pages
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'
bundler-cache: true
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./
destination: ./_site
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

13
Gemfile
View File

@@ -1,5 +1,12 @@
source 'https://rubygems.org'
gem 'jekyll'
gem 'jekyll-feed'
gem 'jekyll-sitemap'
# GitHub Pages compatible gems
gem 'github-pages', group: :jekyll_plugins
gem 'jekyll-feed', '~> 0.12'
gem 'jekyll-sitemap'
# If you want to use GitHub Pages, uncomment the line below and comment out the jekyll gem above
# gem 'github-pages', group: :jekyll_plugins
# For local development, you can use a newer Jekyll version
# gem 'jekyll', '~> 4.3.0'

20
Gemfile.github-pages Normal file
View File

@@ -0,0 +1,20 @@
source 'https://rubygems.org'
# GitHub Pages compatible gems
gem 'github-pages', group: :jekyll_plugins
gem 'jekyll-feed', '~> 0.12'
gem 'jekyll-sitemap'
# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
# and associated library.
platforms :mingw, :x64_mingw, :mswin, :jruby do
gem 'tzinfo', '>= 1', '< 3'
gem 'tzinfo-data'
end
# Performance-booster for watching directories on Windows
gem 'wdm', '~> 0.1.1', :platforms => [:mingw, :x64_mingw, :mswin]
# Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem
# do not have a Java counterpart.
gem 'http_parser.rb', '~> 0.6.0', :platforms => [:jruby]

23
switch-to-github-pages.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
# Script to switch to GitHub Pages compatible setup
echo "Switching to GitHub Pages compatible setup..."
# Backup current Gemfile
cp Gemfile Gemfile.local-dev
# Use GitHub Pages compatible Gemfile
cp Gemfile.github-pages Gemfile
echo "✅ Switched to GitHub Pages compatible setup"
echo "📝 Your local development Gemfile has been backed up as Gemfile.local-dev"
echo ""
echo "To switch back to local development:"
echo " cp Gemfile.local-dev Gemfile"
echo " bundle install"
echo ""
echo "To deploy to GitHub Pages:"
echo " git add ."
echo " git commit -m 'Update for GitHub Pages'"
echo " git push origin main"

16
switch-to-local-dev.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
# Script to switch back to local development setup
echo "Switching to local development setup..."
# Use local development Gemfile
cp Gemfile.local-dev Gemfile
echo "✅ Switched to local development setup"
echo ""
echo "To install dependencies:"
echo " bundle install"
echo ""
echo "To run locally:"
echo " bundle exec jekyll serve"