Skip to content

Instantly share code, notes, and snippets.

@p3palazzo
Created June 18, 2021 19:25
Show Gist options
  • Save p3palazzo/c54afe553d7b74c6845c0f64c1a6e784 to your computer and use it in GitHub Desktop.
Save p3palazzo/c54afe553d7b74c6845c0f64c1a6e784 to your computer and use it in GitHub Desktop.
GitHub workflow to build a Jekyll website on the gh-pages branch
# Builds a Jekyll website on the gh-pages branch
# Using a Makefile.
# Place in <repo>/.github/workflows/
# The gh-pages branch must exist before
# this workflow is run.
name: Jekyll
on:
pull_request:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Test build website
run: make
- name: Upload website
uses: actions/upload-artifact@v2
with:
name: site
path: '_site/*'
commit:
runs-on: ubuntu-latest
needs: [ build ]
if: github.event_name == 'push'
env:
commit_message: ${{ github.event.head_commit.message }}
steps:
- uses: actions/checkout@v2
with:
ref : 'gh-pages'
submodules: 'recursive'
- name: Download site
uses: actions/download-artifact@v2
with:
name: site
path: ${{ github.workspace }}/
- name: Commit changes to gh-pages branch
run: |
cd ${{ github.workspace }}
git config --local user.email "runner@github.com"
git config --local user.name "Automated build"
git add .
git commit -m "${{ env.commit_message }}" -a || git status
git pull --ff-only
git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment