mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Add theme, Python version, siteurl 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.base_url }}"'`
to the `pelican` command to set the value of Pelican's `FEED_DOMAIN`
setting for feed URLs.
4. Add a `feed_domain` input to the workflow so that users can override
the feed domain if they need to.
5. Add a `siteurl` input to the workflow so that users can override the
site URL if they need to.
6. Add a note to the docs about GitHub Pages generating http:// URLs for
https:// sites, and how to fix it
7. Some light editing of the docs for the workflow
99 lines
3.6 KiB
YAML
99 lines
3.6 KiB
YAML
# Workflow for publishing to GitHub Pages. **NO OFFICIAL SUPPORT PROVIDED.**
|
|
name: Deploy to GitHub Pages
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
settings:
|
|
required: true
|
|
description: "The path to your Pelican settings file (`pelican`'s `--settings` option), for example: 'publishconf.py'"
|
|
type: string
|
|
requirements:
|
|
required: false
|
|
default: "pelican"
|
|
description: "The Python requirements to install, for example to enable markdown and typogrify use: 'pelican[markdown] typogrify' or if you have a requirements file use: '-r requirements.txt'"
|
|
type: string
|
|
output-path:
|
|
required: false
|
|
default: "output/"
|
|
description: "Where to output the generated files (`pelican`'s `--output` option)"
|
|
type: string
|
|
theme:
|
|
required: false
|
|
default: ""
|
|
description: "The GitHub repo URL of a custom theme to use, for example: 'https://github.com/seanh/sidecar.git'"
|
|
type: string
|
|
python:
|
|
required: false
|
|
default: "3.12"
|
|
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)"
|
|
type: string
|
|
siteurl:
|
|
required: false
|
|
default: ""
|
|
description: "The base URL of your web site (Pelican's SITEURL setting). If not passed this will default to the URL of your GitHub Pages site, which is correct in most cases."
|
|
type: string
|
|
feed_domain:
|
|
required: false
|
|
default: ""
|
|
description: "The domain to be prepended to feed URLs (Pelican's FEED_DOMAIN setting). If not passed this will default to the URL of your GitHub Pages site, which is correct in most cases."
|
|
type: string
|
|
permissions:
|
|
contents: read
|
|
pages: write
|
|
id-token: write
|
|
concurrency:
|
|
group: "pages"
|
|
cancel-in-progress: false
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: ${{ inputs.python }}
|
|
- name: Checkout theme
|
|
if: ${{ inputs.theme }}
|
|
run: git clone '${{ inputs.theme }}' .theme
|
|
- name: Configure GitHub Pages
|
|
id: pages
|
|
uses: actions/configure-pages@v3
|
|
- name: Install requirements
|
|
run: pip install ${{ inputs.requirements }}
|
|
- name: Build Pelican site
|
|
shell: python
|
|
run: |
|
|
import subprocess
|
|
|
|
cmd = "pelican"
|
|
cmd += " --settings ${{ inputs.settings }}"
|
|
cmd += " --extra-settings"
|
|
cmd += """ SITEURL='"${{ inputs.siteurl || steps.pages.outputs.base_url }}"'"""
|
|
cmd += """ FEED_DOMAIN='"${{ inputs.feed_domain || steps.pages.outputs.base_url }}"'"""
|
|
cmd += " --output ${{ inputs.output-path }}"
|
|
|
|
if "${{ inputs.theme }}":
|
|
cmd += " --theme-path .theme"
|
|
|
|
subprocess.run(cmd, shell=True, check=True)
|
|
- name: Fix permissions
|
|
run: |
|
|
chmod -c -R +rX "${{ inputs.output-path }}" | while read line; do
|
|
echo "::warning title=Invalid file permissions automatically fixed::$line"
|
|
done
|
|
- name: Upload artifact
|
|
uses: actions/upload-pages-artifact@v2
|
|
with:
|
|
path: ${{ inputs.output-path }}
|
|
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@v2
|