Publish site #302
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
name: Publish site | |
on: | |
schedule: | |
- cron: '46 09 * * *' | |
push: | |
branches: [ main ] | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod | |
- name: Build the site | |
run: ./build.sh | |
- name: Push dist to github pages branch | |
shell: bash | |
run: | | |
git config --global user.name "Rouke Broersma" | |
git config --global user.email "[email protected]" | |
GIT_COMMIT=$(git rev-parse HEAD) | |
git fetch | |
git checkout gh-pages | |
sudo chown -R $USER:$USER . | |
ls --hide=dist | xargs sudo rm -r | |
shopt -s dotglob | |
mv dist/* . | |
rmdir dist | |
git add . | |
if [[ -n $(git status -s) ]]; then | |
echo "" | |
echo "Changes found, deploying" | |
git commit -am "Update to $GIT_COMMIT" | |
git push -u origin gh-pages | |
else | |
echo "" | |
echo "There were no changes, skipping.." | |
fi |