Created
June 18, 2021 19:25
-
-
Save p3palazzo/c54afe553d7b74c6845c0f64c1a6e784 to your computer and use it in GitHub Desktop.
GitHub workflow to build a Jekyll website on the gh-pages branch
This file contains 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
# 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