Workflow file for this run
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
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
# GitHub recommends pinning actions to a commit SHA. | |
# To get a newer version, you will need to update the SHA. | |
# You can also reference a tag or branch, but the action may change without warning. | |
name: Create Publish And Test Docker image | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build-and-push-image: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Log in to the Container registry | |
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
container-test-job: | |
runs-on: ubuntu-latest | |
needs: build-and-push-image | |
container: | |
image: ghcr.io/davidpratten/jetisu:latest | |
env: | |
NODE_ENV: development | |
ports: | |
- 80 | |
volumes: | |
- my_docker_volume:/volume_mount | |
options: --cpus 1 | |
steps: | |
- name: Run .py tests | |
# The CD is required because when a container is run by Github the working directory is set by | |
# GITHUB_WORKSPACE environment variable and defaults to /home/runner/work/my-repo-name/my-repo-name. | |
# jovyan is the default non-root username chosen by Docker when building the image | |
# Whereas for reasons that are not immediately apparent, having the current directory on the | |
# python's sys path is a prerequisite when the test holding .py files are at lower levels in the | |
# folder hierarchy and running python -m pytest instead of just pytest accomplishes that :-) | |
run: cd /home/jovyan && python -m pytest | |
- name: Run .ipynb tests | |
run: cd /home/jovyan && python -m pytest --nbmake -n=auto |