clayh53 / tufte-jekyll

Minimal Jekyll blog styled to resemble the look and layout of Edward Tufte's books
MIT License
635 stars 206 forks source link

Alternative deploy to github pages instead of Rakefile #93

Open gareth-cheeseman opened 1 year ago

gareth-cheeseman commented 1 year ago

Not an issue, but putting this here, in case it helps someone else. (thanks for the great theme btw) I didn't want to use the UploadToGithub.Rakefile.

Github pages can now be deployed to with github actions publishing with github actions.

I develop in vscode using a devcontainer docker image, so I used this workflow that is very similar to the github actions default one. The differences are running it in the same container image I develop in and having the plan build step. (the github default one uses their executable that only allows their allowed list of plugins).

# Sample workflow for building and deploying a Jekyll site to GitHub Pages
name: Deploy Jekyll with GitHub Pages dependencies preinstalled

on:
  # Runs on pushes targeting the default branch
  push:
    branches: ["master"]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

# Allow one concurrent deployment
concurrency:
  group: "pages"
  cancel-in-progress: true

jobs:
  build:
    runs-on: ubuntu-latest
    container: mcr.microsoft.com/devcontainers/jekyll:0-bullseye
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Setup Pages
        uses: actions/configure-pages@v3
      - name: Build with Jekyll
        run: |
          bundle install
          jekyll build
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v1

  # Deployment job
  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@v1

This allows me to develop normally with a gitignore that includes the _site folder. And deploys on any push to master.