1
0
Fork 0
forked from github/pelican

Add GitHub Actions workflow for GitHub Pages

Add a GitHub Actions workflow that users can use to publish their
Pelican sites to GitHub Pages by running `pelican` on GitHub Actions,
without having to run `pelican` locally and push the output directory to
a branch.

See: https://github.com/getpelican/pelican/discussions/3174
This commit is contained in:
Sean Hammond 2023-08-28 19:21:03 +01:00
commit 29185e4ad7
No known key found for this signature in database
GPG key ID: 17C7DAFDB3DD8A84
2 changed files with 166 additions and 13 deletions

61
.github/workflows/github_pages.yml vendored Normal file
View file

@ -0,0 +1,61 @@
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'"
type: string
output-path:
required: false
default: "output/"
description: "Where to output the generated files (`pelican`'s `--output` option)"
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@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Configure GitHub Pages
id: pages
uses: actions/configure-pages@v3
- name: Install requirements
run: pip install ${{ inputs.requirements }}
- name: Build Pelican site
run: |
pelican \
--settings "${{ inputs.settings }}" \
--extra-settings SITEURL='"${{ steps.pages.outputs.base_url }}"' \
--output "${{ inputs.output-path }}"
- 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