Skip to content

Merge pull request #12 from andrevidela/pack-documentation-download #33

Merge pull request #12 from andrevidela/pack-documentation-download

Merge pull request #12 from andrevidela/pack-documentation-download #33

Workflow file for this run

## 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:
- main
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://www.idris-lang.org/"
REQUIREMENTS: "-r requirements.txt"
# FIXME: remove once official action can be used
OUTPUT_PATH: "output/"
WORKING_DIR: "./src"
# 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: "${{ env.WORKING_DIR }}/${{ env.OUTPUT_PATH }}"
deploy:
concurrency:
group: "pages"
cancel-in-progress: 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