Skip to content

Commit bf166df

Browse files
authored
Merge pull request #104 from makeabilitylab/ci/github-actions-jekyll-deploy
Add GitHub Actions Jekyll build + deploy workflow (#98)
2 parents 303aa43 + 7dd87da commit bf166df

2 files changed

Lines changed: 91 additions & 0 deletions

File tree

.github/workflows/jekyll.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Build the Jekyll site with GitHub Actions and deploy it to GitHub Pages.
2+
#
3+
# This replaces the default "deploy from a branch" GitHub Pages build (which
4+
# only runs whitelisted plugins and no custom build steps) with a full
5+
# `bundle exec jekyll build` running in CI. That unlocks custom plugins,
6+
# build-time code inlining, and content lint/test gates. See issue #98.
7+
#
8+
# IMPORTANT: this workflow only takes over publishing once the repo's
9+
# Pages "Source" is switched from "Deploy from a branch" to "GitHub Actions"
10+
# (Settings -> Pages -> Build and deployment -> Source). Until then it builds
11+
# but the deploy step will not publish.
12+
name: Build and deploy Jekyll site to Pages
13+
14+
on:
15+
# Run on every push to the live branch.
16+
push:
17+
branches: ["main"]
18+
# Allow manual runs from the Actions tab.
19+
workflow_dispatch:
20+
21+
# Minimum permissions the deploy job needs to publish to Pages.
22+
permissions:
23+
contents: read
24+
pages: write
25+
id-token: write
26+
27+
# Allow one concurrent deployment; don't cancel an in-progress production
28+
# deploy if another push lands while it's running.
29+
concurrency:
30+
group: "pages"
31+
cancel-in-progress: false
32+
33+
jobs:
34+
build:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v4
39+
40+
- name: Setup Ruby
41+
uses: ruby/setup-ruby@v1
42+
with:
43+
# Matches .ruby-version. bundler-cache installs the Gemfile (still
44+
# the github-pages gem, so the build is byte-for-byte the current
45+
# one) and caches gems between runs.
46+
ruby-version: "3.3.11"
47+
bundler-cache: true
48+
cache-version: 0
49+
50+
- name: Setup Pages
51+
id: pages
52+
uses: actions/configure-pages@v5
53+
54+
- name: Build with Jekyll
55+
# base_path comes out as "/physcomp", matching baseurl in _config.yml.
56+
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
57+
env:
58+
JEKYLL_ENV: production
59+
60+
- name: Upload artifact
61+
uses: actions/upload-pages-artifact@v3
62+
63+
deploy:
64+
needs: build
65+
runs-on: ubuntu-latest
66+
environment:
67+
name: github-pages
68+
url: ${{ steps.deployment.outputs.page_url }}
69+
steps:
70+
- name: Deploy to GitHub Pages
71+
id: deployment
72+
uses: actions/deploy-pages@v4

website-dev.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@ Assuming you have the prerequisite libraries and software infrastructure (e.g.,
2424
> bundle exec jekyll serve
2525
```
2626

27+
## Deployment (GitHub Actions)
28+
29+
The live site at <https://makeabilitylab.github.io/physcomp/> is built and
30+
published by the GitHub Actions workflow in
31+
[`.github/workflows/jekyll.yml`](.github/workflows/jekyll.yml). On every push to
32+
`main` (and on manual runs from the **Actions** tab), the workflow runs
33+
`bundle exec jekyll build` on a clean Ubuntu runner and deploys the resulting
34+
`_site/` to GitHub Pages with `actions/deploy-pages`.
35+
36+
This replaced the older "Deploy from a branch" GitHub Pages build, which only
37+
ran whitelisted plugins and no custom build steps. Building in Actions lets us
38+
run custom Jekyll plugins, inline source code at build time, and add content
39+
lint/test gates. See [issue #98](https://github.com/makeabilitylab/physcomp/issues/98).
40+
41+
For the Actions deploy to publish, the repo's **Settings → Pages → Build and
42+
deployment → Source** must be set to **GitHub Actions** (not "Deploy from a
43+
branch"). The workflow still installs the same `github-pages` gem from the
44+
`Gemfile`, so the built output matches the previous branch-based build.
45+
2746
## VS Code
2847
I've been using [VS Code](https://code.visualstudio.com/) with some popular markdown extensions to develop the website.
2948

0 commit comments

Comments
 (0)