Skip to content

Instantly share code, notes, and snippets.

@vsoch
Created September 6, 2021 23:04
Show Gist options
  • Save vsoch/11b9ce5045b7ad28787cdf090313b441 to your computer and use it in GitHub Desktop.
Save vsoch/11b9ce5045b7ad28787cdf090313b441 to your computer and use it in GitHub Desktop.
name: generate-site
on:
pull_request: []
push:
branches:
- "main"
jobs:
Update:
name: Build and Deploy Interface
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Convert LaTex Files
run: |
docker build -t latex2md .
docker run -i -v $PWD:/code latex2md
git status
- name: Build Jekyll site
run: |
set -xo pipefail
rm -rf _site/*
docker run --rm \
-v "$PWD:/srv/jekyll" -v "$PWD/_site:/srv/jekyll/_site" \
jekyll/builder:4.0 /bin/bash -c "chmod -R 777 /srv/jekyll && jekyll build --future && chmod -R 777 /srv/jekyll"
- name: Deploy to gh-pages
if: (github.event_name == 'push')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
printf "GitHub Actor: ${GITHUB_ACTOR}\n"
git config user.name "github-actions"
git config user.email "[email protected]"
git config pull.rebase false
git fetch || printf "fetch did not work\n"
git checkout -b gh-pages || git checkout gh-pages
git status
ls -Q | grep -v _site | xargs rm -rf
mv _site/* .
rm -rf _site
rm -rf .jekyll-cache
[[ -n "$(git status --porcelain)" ]] || exit 0
git add .
git commit -m "Build $(git rev-parse source | grep -o '^.\{10\}')"
git push origin gh-pages --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment