update deploy #792
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
| # General notes on github actions: Note that both the working directory | |
| # and environment variables generally are not shared between steps. | |
| name: deploy tylr | |
| on: [push] | |
| jobs: | |
| Deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # NOTE: position the below lines in the code between two steps | |
| # and uncomment them to open an ssh connection at that point: | |
| #- name: Debugging with ssh | |
| # uses: lhotari/action-upterm@v1 | |
| - name: Checkout tylr repo on current branch # STEP 1 | |
| uses: actions/checkout@v2 | |
| with: | |
| path: source | |
| - name: Add name of current branch to environment as BRANCH_NAME | |
| uses: nelonoel/[email protected] | |
| - name: Set-up OCaml | |
| uses: ocaml/setup-ocaml@v3 | |
| with: | |
| ocaml-compiler: 5.0.0 | |
| dune-cache: true | |
| - name: Retrieve the switch environment if cached | |
| id: opam-cache-switch | |
| uses: actions/cache@v4 | |
| with: | |
| path: "_opam" | |
| key: ${{ runner.os }}-modules-${{ hashFiles('./source/opam.export') }} | |
| - name: Add opam repository archive | |
| run: | | |
| eval $(opam env) | |
| export OPAMYES=1 | |
| opam repo add archive git+https://github.com/ocaml/opam-repository-archive | |
| - name: Install dependencies | |
| run: | | |
| eval $(opam env) | |
| export OPAMYES=1 | |
| export DUNE_CACHE=enabled | |
| # opam install . --deps-only --with-test --locked | |
| make deps | |
| working-directory: ./source | |
| - name: Clean opam switch | |
| run: | | |
| eval $(opam env) | |
| export OPAMYES=1 | |
| opam clean --all-switches --download-cache --logs --repo-cache --unused-repositories | |
| - name: Build Release | |
| run: | | |
| export DUNE_CACHE=enabled | |
| opam exec -- dune build @src/fmt --auto-promote src --profile release | |
| working-directory: ./source | |
| - name: Checkout website build artifacts repo # STEP 4 | |
| uses: actions/checkout@v2 | |
| with: | |
| repository: hazelgrove/tylr-build | |
| token: ${{ secrets.DEPLOY_TYLR }} | |
| path: server | |
| - name: Clear any old build of this branch # STEP 5 | |
| run: if [ -d "${BRANCH_NAME}" ] ; then rm -rf "${BRANCH_NAME}" ; fi | |
| working-directory: ./server | |
| - name: Copy in newly built source # STEP 6 | |
| run: | | |
| mkdir "./server/${BRANCH_NAME}" && | |
| cp -r "./source/_build/default/src/web/www"/* "./server/${BRANCH_NAME}" && | |
| if [ "${BRANCH_NAME}" == "plus" ] | |
| then | |
| cp -r "./source/_build/default/src/web/www"/* "./server" | |
| fi | |
| - name: Commit to website aka deploy # STEP 7 | |
| run: | | |
| git config user.name github-deploy-action | |
| git config user.email [email protected] | |
| git add -A | |
| git status | |
| git diff-index --quiet HEAD || (git commit -m "github-deploy-action-${BRANCH_NAME}"; git push) | |
| working-directory: ./server |