Deploy Pelican site to GH Pages #22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Workflow for building the site and (optionally) publishing it to GitHub | ||
## Pages. | ||
## The contents of this file were based on the existing deployment templates in | ||
## https://github.com/actions/starter-workflows/tree/main/pages | ||
## as well as the official Pelican GH Pages action at | ||
## https://github.com/getpelican/pelican/blob/main/.github/workflows/github_pages.yml | ||
name: Deploy Pelican site to GH Pages | ||
on: | ||
push: | ||
branches: [$default-branch] | ||
workflow_dispatch: | ||
### This will be really convenient if/when actions supports changing working dir | ||
###jobs: | ||
### deploy: | ||
### uses: "getpelican/pelican/.github/workflows/github_pages.yml@main" | ||
### # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | ||
### permissions: | ||
### contents: read | ||
### pages: write | ||
### id-token: write | ||
### with: | ||
### settings: "publishconf.py" | ||
### python: "3.9" | ||
### # TODO: update when officially switching to community-managed page | ||
### siteurl: "https://test.idris-lang.org/" | ||
### requirements: "-r requirements.txt" | ||
### # FIXME: remove when workflow is no longer bitrotted | ||
### deploy: false | ||
### For now, we will just copy the Pelican CI and cd "manually" | ||
# c.f. https://docs.github.com/en/actions/how-tos/writing-workflows/choosing-what-your-workflow-does/setting-a-default-shell-and-working-directory | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: ./src | ||
env: | ||
SETTINGS: "publishconf.py" | ||
PYTHON: "3.9" | ||
# TODO: update when officially switching to community-managed page | ||
SITEURL: "https://test.idris-lang.org/" | ||
REQUIREMENTS: "-r requirements.txt" | ||
# FIXME: remove once official action can be used | ||
OUTPUT_PATH: "output/" | ||
# Allow one concurrent deployment | ||
concurrency: | ||
group: "pages" | ||
cancel-in-progress: true | ||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | ||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ env.PYTHON }} | ||
- name: Checkout theme | ||
if: ${{ env.THEME }} | ||
run: git clone '${{ env.THEME }}' .theme | ||
- name: Configure GitHub Pages | ||
id: pages | ||
uses: actions/configure-pages@v5 | ||
- name: Install requirements | ||
run: pip install ${{ env.REQUIREMENTS }} | ||
- name: Build Pelican site | ||
shell: python | ||
run: | | ||
import subprocess | ||
cmd = "pelican" | ||
cmd += " --settings ${{ env.SETTINGS }}" | ||
cmd += " --extra-settings" | ||
cmd += """ SITEURL='"${{ env.SITEURL || steps.pages.outputs.base_url }}"'""" | ||
cmd += """ FEED_DOMAIN='"${{ env.FEED_DOMAIN || steps.pages.outputs.base_url }}"'""" | ||
cmd += " --output ${{ env.OUTPUT_PATH }}" | ||
if "${{ env.THEME }}": | ||
cmd += " --theme-path .theme" | ||
subprocess.run(cmd, shell=True, check=True) | ||
- name: Fix permissions | ||
run: | | ||
chmod -c -R +rX "${{ env.OUTPUT_PATH }}" | while read line; do | ||
echo "::warning title=Invalid file permissions automatically fixed::$line" | ||
done | ||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: "${{ defaults.run.working-dir }}/${{ env.OUTPUT_PATH }}" | ||
Check failure on line 105 in .github/workflows/pelican.yml
|
||
deploy: | ||
concurrency: | ||
group: "pages" | ||
cancel-in-progress: false | ||
# FIXME: remove when workflow is no longer bitrotted | ||
if: false | ||
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@v4 | ||