Skip to content

Instantly share code, notes, and snippets.

@mmcinnestaylor
Last active January 31, 2024 22:01
Show Gist options
  • Save mmcinnestaylor/ff4cdbb5f0b9ae27c18ccc16c86b16f2 to your computer and use it in GitHub Desktop.
Save mmcinnestaylor/ff4cdbb5f0b9ae27c18ccc16c86b16f2 to your computer and use it in GitHub Desktop.
Deploy al-folio themed Jekyll site to Cloudflare Pages

al-folio + Cloudflare Pages

The Jekyll al-folio theme requires a working Jupyter installation to successfully build the site. The default Cloudflare Pages Jekyll builder does not include a Jupyter installation. Instead of building the site on the Cloudflare platform, one can build and deploy the site using GitHub Actions.

In order to utilize both Production and Preview deployments in Cloudflare Pages, update the .github/workflows/broken-links.yml workflow to include the desired development branch(es), and utilize the github.event.workflow_run.head_branch attribute in the checkout and delpoy steps within deploy.yml.

References

name: Deploy site
on:
workflow_run:
workflows: [Check for broken links]
types: [completed]
workflow_dispatch:
permissions:
contents: write
jobs:
deploy:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-a-workflow-based-on-the-conclusion-of-another-workflow
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
# available images: https://github.com/actions/runner-images#available-images
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch }}
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2.2"
bundler-cache: true
- name: Update _config.yml ⚙️
uses: fjogeleit/yaml-update-action@main
with:
commitChange: false
valueFile: "_config.yml"
propertyPath: "giscus.repo"
value: ${{ github.repository }}
- name: Install and Build 🔧
run: |
pip3 install --upgrade jupyter
npm install -g mermaid.cli
export JEKYLL_ENV=production
bundle exec jekyll build --lsi
- name: Purge unused CSS 🧹
run: |
npm install -g purgecss
purgecss -c purgecss.config.js
- name: Deploy to Cloudflare Pages 🚀
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: # your Cloudflare Pages project name
directory: _site
branch: ${{ github.event.workflow_run.head_branch }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment