Update Forest Submodule and Deploy #8
This file contains hidden or 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: Update Forest Submodule and Deploy | |
| on: | |
| repository_dispatch: | |
| types: [submodule-updated] | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 */6 * * *' # Fallback check every 6 hours | |
| env: | |
| FORESTER_BRANCH : forester-5.0-dev | |
| CACHE_PATHS: | | |
| ~/.opam | |
| jobs: | |
| update-and-deploy: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Needed for pushing updates | |
| pages: write # Needed for deploying to Pages | |
| steps: | |
| - name: Set up OCaml | |
| uses: ocaml/setup-ocaml@v3 | |
| with: | |
| ocaml-compiler: 5.2.0 | |
| - name: Restore Forester | |
| uses: actions/cache/restore@v3 | |
| id: cache-forester-restore | |
| with: | |
| path: ${{ env.CACHE_PATHS }} | |
| key: ${{ runner.os }}-${{ env.FORESTER_BRANCH }} | |
| - name: Download and install Forester | |
| if: steps.cache-forester-restore.outputs.cache-hit != 'true' | |
| run: | | |
| opam update | |
| eval $(opam env --switch=5.2.0) | |
| git clone https://git.sr.ht/~jonsterling/ocaml-forester | |
| cd ocaml-forester | |
| git checkout ${{ env.FORESTER_BRANCH }} | |
| opam exec -- dune build | |
| opam exec -- dune install | |
| cd .. | |
| - name: Save Forester | |
| if: steps.cache-forester-restore.outputs.cache-hit != 'true' | |
| uses: actions/cache/save@v3 | |
| id: cache-forester-save | |
| with: | |
| path: ${{ env.CACHE_PATHS }} | |
| key: ${{ steps.cache-forester-restore.outputs.cache-primary-key }} | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| with: | |
| submodules: true | |
| token: ${{ secrets.ACCESS_TOKEN }} | |
| - name: Update submodule | |
| run: | | |
| git config --global user.name "GitHub Actions" | |
| git config --global user.email "actions@github.com" | |
| git submodule update --remote --recursive | |
| git diff --exit-code || (git add . && git commit -m "Update forest submodule" && git push) | |
| - name: Build site | |
| run: | | |
| ./build.sh | |
| - name: Deploy to GitHub Pages | |
| uses: JamesIves/github-pages-deploy-action@v4 | |
| with: | |
| branch: gh-pages | |
| folder: build | |
| token: ${{ secrets.ACCESS_TOKEN }} |