Build and Deploy to Github Pages #1568
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: Build and Deploy to Github Pages | |
on: | |
push: | |
branches: | |
- master | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v2 | |
with: | |
submodules: true | |
- name: Install dependencies | |
uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
ruby-version: 3.0.2 | |
working-directory: docs | |
- name: Generate model firmware redirects | |
run: | | |
sudo pip3 install shyaml | |
bash docs/_data/genmodelfw.sh | |
- name: Build page | |
run: | | |
cd docs | |
bundle exec jekyll build | |
- name: Commit changes | |
run: | | |
cd docs/_site | |
git init | |
git add . | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config user.name "github-actions[bot]" | |
git commit -m "Jekyll build from ${GITHUB_SHA}" | |
- name: Check if changes were made | |
id: check | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
changed=0 | |
cd docs/_site | |
git remote add origin https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} | |
git fetch origin gh-pages || changed=1 | |
git diff --exit-code origin/gh-pages ':!feed.xml' || changed=1 | |
echo ::set-output name=changed::$changed | |
- name: Push changes to repo | |
if: steps.check.outputs.changed == 1 | |
run: | | |
cd docs/_site | |
git push origin HEAD:gh-pages --force |