Docs/schema change #393
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
name: Docker - build, test, push | |
# This workflow will build docker image and run tests inside the container. | |
# This workflow is only executed if there is pull request with change in pyproject.toml dependencies, | |
# or in Dockerfile, or in docker workflow. | |
on: | |
pull_request: | |
paths: | |
- '.github/workflows/docker-image.yml' | |
- 'pyproject.toml' | |
- 'Dockerfile' | |
push: | |
branches: | |
- 'develop' | |
release: | |
types: [published] | |
# allows to manually start a workflow run from the GitHub UI or using the GitHub API. | |
workflow_dispatch: | |
inputs: | |
push-image: | |
description: "Push image to docker hub" | |
required: false | |
type: boolean | |
default: false | |
push-description: | |
description: "Update docker hub description" | |
required: false | |
type: boolean | |
default: false | |
tag: | |
description: "Tag for the docker image" | |
required: false | |
default: "workflow-dispatch" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# We do not bother with setup-qemu-action since we don't care about emulation right now | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
tags: aiod/metadata_catalogue:ci | |
outputs: type=docker,dest=/tmp/aiod_mc_image.tar | |
cache-from: type=gha | |
cache-to: type=gha,mode=min | |
# We store the image as an artifact, so it can be used by the `test` step | |
# and inspected manually if needed (download it through Github Actions UI) | |
- name: Store Image | |
uses: actions/upload-artifact@v4 | |
with: | |
name: aiod_mc_image | |
path: /tmp/aiod_mc_image.tar | |
test: | |
runs-on: ubuntu-latest | |
needs: [build] | |
steps: | |
# We need to check out the repository, so that we have the `scripts` directory to mount. | |
# This is required to run the backup script tests. | |
- uses: actions/checkout@v4 | |
- name: Retrieve Image | |
uses: actions/download-artifact@v4 | |
with: | |
name: aiod_mc_image | |
path: /tmp | |
- name: Load Image | |
run: | | |
docker load --input /tmp/aiod_mc_image.tar | |
docker image ls -a | |
- name: Run pytest from docker | |
run: | | |
docker run -v ./scripts:/scripts -e KEYCLOAK_CLIENT_SECRET="mocked_secret" --entrypoint "" aiod/metadata_catalogue:ci sh -c "pip install \".[dev]\" && pytest tests -s" | |
publish: | |
needs: [test] | |
runs-on: ubuntu-latest | |
if: github.event_name != 'pull_request' | |
steps: | |
# The correct tag depends on how this workflow was invoked, see also docker-description.md | |
- name: Set Develop Tag | |
if: github.ref == 'refs/heads/develop' | |
run: echo "IMAGE_TAGS=aiod/metadata_catalogue:develop" >> "$GITHUB_ENV" | |
- name: Set Release Tag | |
if: github.event_name == 'release' | |
run: echo "IMAGE_TAGS=aiod/metadata_catalogue:latest,aiod/metadata_catalogue:${{ github.event.release.tag_name }}" >> "$GITHUB_ENV" | |
- name: Set Dispatch Tag | |
if: github.event_name == 'workflow_dispatch' | |
run: echo "IMAGE_TAGS=aiod/metadata_catalogue:${{ inputs.tag }}" >> "$GITHUB_ENV" | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.AIOD_DOCKER_PAT }} | |
- name: Echo tags | |
run: echo $IMAGE_TAGS | |
- name: Build | |
if: (github.event_name != 'workflow_dispatch') || inputs.push-image | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
context: . | |
file: ./Dockerfile | |
tags: ${{ env.IMAGE_TAGS }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=min | |
- name: Update repository description | |
if: (github.event_name == 'release') || inputs.push-description | |
uses: peter-evans/dockerhub-description@v4 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.AIOD_DOCKER_PAT }} | |
repository: aiod/metadata_catalogue | |
readme-filepath: ./docker-description.md | |
short-description: "Metadata catalogue REST API for AI on Demand." |