Skip to content

Commit 1dda646

Browse files
committed
Enable github forks to override jekyll config
The github build action will dump a `JEKYLL_CONFIG_OVERRIDES` action variable into a file `_config-overrides.yml` which will override whatever you want in `_config.yml`. Why: It's convenient to be able to deploy the website on a forked repository. Currently this doesn't work smoothly because by default with actions because it builds with kroxylicious.io as the url. The mechanism that configures the baseurl is also not wired up correctly. To override the url we need to add in an override configuration, so I figure we should use the same mechanism to override baseurl. The fork can set a variable containing both these values. Signed-off-by: Robert Young <[email protected]>
1 parent 117ac14 commit 1dda646

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

.github/workflows/jekyll-gh-pages.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ jobs:
5959
tags: localhost:5000/kroxy-jekyll:latest
6060
cache-from: type=gha
6161
cache-to: type=gha,mode=max
62+
- name: Load Jekyll configuration overrides
63+
# this is to enable forks to override the url and baseurl
64+
run: echo "${{ vars.JEKYLL_CONFIG_OVERRIDES }}" > _config-overrides.yml
6265
- name: Build with Jekyll
6366
# Outputs to the './_site' directory by default
6467
run: |
@@ -67,7 +70,7 @@ jobs:
6770
-u "$(id -u):$(id -g)" \
6871
-v "$(pwd):/site" \
6972
localhost:5000/kroxy-jekyll:latest \
70-
bash -c 'eval "$(rbenv init -)" && cp -r /css/_sass/bootstrap /site/_sass/ && bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"'
73+
bash -c 'eval "$(rbenv init -)" && cp -r /css/_sass/bootstrap /site/_sass/ && bundle exec jekyll build --config=_config.yml,_config-overrides.yml'
7174
env:
7275
JEKYLL_ENV: production
7376
- name: Upload artifact

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ _site
55
vendor
66
.idea
77
*.iml
8-
*/bootstrap/
8+
*/bootstrap/
9+
_config-overrides.yml

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,26 @@ To build and serve the website from a container you can run `./run.sh`. It will
2727

2828
This assumes the use of `podman`, if you are a `docker` user you can run `CONTAINER_ENGINE=docker ./run.sh`.
2929

30+
### Running on GitHub Pages on a Fork
31+
32+
To exercise the GitHub workflows and share changes it can be convenient to deploy a fork to GitHub Pages.
33+
34+
To enable pages on your fork:
35+
1. go to `https://github.com/${yourname}/kroxylicious.github.io/settings` in a browser, replacing `${yourname}` with your GitHub username.
36+
2. Navigate to "Pages" under "Code and automation"
37+
3. Under "Build and deployment", under "Source", select "Github Actions".
38+
4. Navigate to "Actions" under "Secrets and variables" under "Security"
39+
5. Select the "Variables" tab
40+
6. Click "New repository variable"
41+
7. Create a new repository variable named `JEKYLL_CONFIG_OVERRIDES` with value:
42+
```yaml
43+
baseurl: "kroxylicious.github.io"
44+
url: "https://${yourname}.github.io"
45+
```
46+
replacing `${yourname}` with your GitHub username.
47+
8. Push changes to any branch of your fork and then trigger a manual run of `https://github.com/${yourname}/kroxylicious.github.io/actions/workflows/jekyll-gh-pages.yml`,
48+
supplying the branch you want to checkout and deploy as a parameter.
49+
3050
# Binary content
3151

3252
We have an ever-growing collection of binary assets, mostly images but also a few PDF slide decks etc all of these

0 commit comments

Comments
 (0)