Update to use newer version of FEniCSx #299
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
# Publish the Jupyter Book from source files | |
name: publish-book | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build-docker: | |
# This job checks if the Dockerfile has changed. If it has, it then rebuilds the docker image | |
runs-on: ubuntu-latest | |
outputs: | |
dockertag: ${{ steps.dockertag.outputs.tag }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Get main branch | |
run: git clone https://github.com/ukan-computational-acoustics/ca-knowledgebase.git ca-main | |
- name: Go back a commit | |
run: | | |
cd ca-main | |
git reset HEAD~1 | |
git stash | |
cd .. | |
if: github.ref == 'refs/heads/main' | |
- name: Get old Dockerfile | |
run: | | |
cp ca-main/docker/Dockerfile docker/Dockerfile.old | |
rm -rf ca-main | |
- name: compare Dockerfile with old Dockerfile | |
id: diff | |
run: | | |
if diff docker/Dockerfile docker/Dockerfile.old > /dev/null; then | |
echo ::set-output name=changed::no | |
else | |
echo ::set-output name=changed::yes | |
fi | |
- name: set Docker tag | |
run: | | |
if [ "${{ github.ref }}" = "refs/heads/main" ]; then | |
echo ::set-output name=tag::main | |
elif [ "${{ steps.diff.outputs.changed }}" = "yes" ]; then | |
the_tag=($(echo "${{ github.ref }}" | sha1sum)) | |
echo ::set-output name=tag::$the_tag | |
else | |
echo ::set-output name=tag::main | |
fi | |
id: dockertag | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
if: steps.diff.outputs.changed == 'yes' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
if: steps.diff.outputs.changed == 'yes' | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v3 | |
with: | |
push: true | |
tags: caknowledgebase/caknowledgebase:${{ steps.dockertag.outputs.tag }} | |
target: ca-knowledgebase | |
file: docker/Dockerfile | |
if: steps.diff.outputs.changed == 'yes' | |
run-tests: | |
# This job tests that all the scripts run successfully, and runs style checks | |
runs-on: ubuntu-latest | |
container: caknowledgebase/caknowledgebase:${{ needs.build-docker.outputs.dockertag }} | |
needs: | |
- build-docker | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install flake8 and pytest | |
run: pip3 install flake8 pytest flake8-nb nbconvert | |
- name: Run flake8 checks | |
run: flake8 . | |
# - name: Run flake8-nb checks | |
# run: flake8-nb . | |
- name: Run Python tests | |
run: | | |
export PYVISTA_OFF_SCREEN=true | |
pytest _test | |
build-book: | |
# This job installs dependencies and builds the book | |
runs-on: ubuntu-latest | |
container: caknowledgebase/caknowledgebase:${{ needs.build-docker.outputs.dockertag }} | |
needs: | |
- build-docker | |
env: | |
PYVISTA_TRAME_SERVER_PROXY_PREFIX: "/proxy/" | |
PYVISTA_TRAME_SERVER_PROXY_ENABLED: "True" | |
PYVISTA_OFF_SCREEN: false | |
PYVISTA_JUPYTER_BACKEND: "html" | |
DISPLAY: ":99.0" | |
steps: | |
- uses: actions/checkout@v2 | |
# Build the book | |
- name: Build the book | |
run: | | |
PYVISTA_JUPYTER_BACKEND=static PYVISTA_OFF_SCREEN=false jupyter-book build . | |
deploy-book: | |
# If the branch is main, this job builds the book and pushes it to GitHub pages | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
container: caknowledgebase/caknowledgebase:${{ needs.build-docker.outputs.dockertag }} | |
needs: | |
- build-docker | |
env: | |
PYVISTA_TRAME_SERVER_PROXY_PREFIX: "/proxy/" | |
PYVISTA_TRAME_SERVER_PROXY_ENABLED: "True" | |
PYVISTA_OFF_SCREEN: false | |
PYVISTA_JUPYTER_BACKEND: "html" | |
DISPLAY: ":99.0" | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
steps: | |
- uses: actions/checkout@v2 | |
# Build the book | |
- name: Build the book | |
run: | | |
PYVISTA_JUPYTER_BACKEND=static PYVISTA_OFF_SCREEN=false jupyter-book build . | |
# Push to GitHub Pages | |
- name: Setup Pages | |
uses: actions/configure-pages@v3 | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v1 | |
with: | |
path: '_build/html' | |
if: github.ref == 'refs/heads/main' | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v1 | |
if: github.ref == 'refs/heads/main' | |