Skip to content

Commit 78db58d

Browse files
committed
Add theme, Python version and feed domain to GitHub Pages deployment workflow
Add theme, Python version and feed domain support to the reusable GitHub Actions workflow for deploying a Pelican site to GitHub Pages: 1. Add a new `theme` option to the workflow that callers can use to specify an external theme to be checked out and used 2. Add a new `python` option to the workflow that callers can use to specify the Python version, in case they need to build their site with a particular version of Python 3. Pass `--extra-settings FEED_DOMAIN='"${{ steps.pages.outputs.origin }}"'` to the `pelican` command to set the value of Pelican's `FEED_DOMAIN` setting for feed URLs.
1 parent 657ad64 commit 78db58d

File tree

2 files changed

+59
-24
lines changed

2 files changed

+59
-24
lines changed

.github/workflows/github_pages.yml

+28-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ on:
1717
default: "output/"
1818
description: "Where to output the generated files (`pelican`'s `--output` option)"
1919
type: string
20+
theme:
21+
required: false
22+
default: ""
23+
description: "The GitHub repo URL of a custom theme to use, for example: 'https://github.com/seanh/sidecar.git'"
24+
type: string
25+
python:
26+
required: false
27+
default: "3.12"
28+
description: "The version of Python to use, for example: '3.12' (to use the most recent version of Python 3.12, this is faster) or '3.12.1' (to use an exact version, slower)"
29+
type: string
2030
permissions:
2131
contents: read
2232
pages: write
@@ -33,18 +43,31 @@ jobs:
3343
- name: Set up Python
3444
uses: actions/setup-python@v4
3545
with:
36-
python-version: "3.11"
46+
python-version: ${{ inputs.python }}
47+
- name: Checkout theme
48+
if: ${{ inputs.theme }}
49+
run: git clone '${{ inputs.theme }}' .theme
3750
- name: Configure GitHub Pages
3851
id: pages
3952
uses: actions/configure-pages@v3
4053
- name: Install requirements
4154
run: pip install ${{ inputs.requirements }}
4255
- name: Build Pelican site
56+
shell: python
4357
run: |
44-
pelican \
45-
--settings "${{ inputs.settings }}" \
46-
--extra-settings SITEURL='"${{ steps.pages.outputs.base_url }}"' \
47-
--output "${{ inputs.output-path }}"
58+
import subprocess
59+
60+
cmd = "pelican"
61+
cmd += " --settings ${{ inputs.settings }}"
62+
cmd += " --extra-settings"
63+
cmd += """ SITEURL='"${{ steps.pages.outputs.base_url }}"'"""
64+
cmd += """ FEED_DOMAIN='"${{ steps.pages.outputs.origin }}"'"""
65+
cmd += " --output ${{ inputs.output-path }}"
66+
67+
if "${{ inputs.theme }}":
68+
cmd += " --theme-path .theme"
69+
70+
subprocess.run(cmd, shell=True, check=True)
4871
- name: Fix permissions
4972
run: |
5073
chmod -c -R +rX "${{ inputs.output-path }}" | while read line; do

docs/tips.rst

+31-19
Original file line numberDiff line numberDiff line change
@@ -176,25 +176,35 @@ for more information.
176176
A number of optional inputs can be added to the ``with:`` block when calling
177177
the workflow:
178178

179-
+--------------+----------+-----------------------------------+--------+---------------+
180-
| Name | Required | Description | Type | Default |
181-
+==============+==========+===================================+========+===============+
182-
| settings | Yes | The path to your Pelican settings | string | |
183-
| | | file (``pelican``'s | | |
184-
| | | ``--settings`` option), | | |
185-
| | | for example: ``"publishconf.py"`` | | |
186-
+--------------+----------+-----------------------------------+--------+---------------+
187-
| requirements | No | The Python requirements to | string | ``"pelican"`` |
188-
| | | install, for example to enable | | |
189-
| | | markdown and typogrify use: | | |
190-
| | | ``"pelican[markdown] typogrify"`` | | |
191-
| | | or if you have a requirements | | |
192-
| | | file: ``"-r requirements.txt"`` | | |
193-
+--------------+----------+-----------------------------------+--------+---------------+
194-
| output-path | No | Where to output the generated | string | ``"output/"`` |
195-
| | | files (``pelican``'s ``--output`` | | |
196-
| | | option) | | |
197-
+--------------+----------+-----------------------------------+--------+---------------+
179+
+--------------+----------+--------------------------------------------+--------+---------------+
180+
| Name | Required | Description | Type | Default |
181+
+==============+==========+============================================+========+===============+
182+
| settings | Yes | The path to your Pelican settings | string | |
183+
| | | file (``pelican``'s | | |
184+
| | | ``--settings`` option), | | |
185+
| | | for example: ``"publishconf.py"`` | | |
186+
+--------------+----------+--------------------------------------------+--------+---------------+
187+
| requirements | No | The Python requirements to | string | ``"pelican"`` |
188+
| | | install, for example to enable | | |
189+
| | | markdown and typogrify use: | | |
190+
| | | ``"pelican[markdown] typogrify"`` | | |
191+
| | | or if you have a requirements | | |
192+
| | | file: ``"-r requirements.txt"`` | | |
193+
+--------------+----------+--------------------------------------------+--------+---------------+
194+
| output-path | No | Where to output the generated | string | ``"output/"`` |
195+
| | | files (``pelican``'s ``--output`` | | |
196+
| | | option) | | |
197+
+--------------+----------+--------------------------------------------+--------+---------------+
198+
| theme | No | The GitHub repo URL of a custom | string | ``""`` |
199+
| | | theme to use, for example: | | |
200+
| | | ``"https://github.com/seanh/sidecar.git"`` | | |
201+
+--------------+----------+--------------------------------------------+--------+---------------+
202+
| python | No | The version of Python to use to build the | string | ``"3.12"`` |
203+
| | | site, for example: ``"3.12"`` (to use the | | |
204+
| | | most recent version of Python 3.12, this | | |
205+
| | | is faster) or ``"3.12.1"`` (to use an | | |
206+
| | | exact version, slower) | | |
207+
+--------------+----------+--------------------------------------------+--------+---------------+
198208

199209
For example:
200210

@@ -204,6 +214,8 @@ For example:
204214
settings: "publishconf.py"
205215
requirements: "pelican[markdown] typogrify"
206216
output-path: "__output__/"
217+
theme: "https://github.com/seanh/sidecar.git"
218+
python: "3.12"
207219
208220
Custom 404 Pages
209221
----------------

0 commit comments

Comments
 (0)