Skip to content

99 update documentation #140

99 update documentation

99 update documentation #140

name: Docker Image CI
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
OPENEM_FLOWS_IMAGE_NAME: ${{ github.repository }}-openem-flows
OPENEM_BACKEND_IMAGE_NAME: ${{ github.repository }}-openem-backend
OPENEM_CONFIG_IMAGE_NAME: ${{ github.repository }}-openem-config
SCICAT_MOCK_IMAGE_NAME: ${{ github.repository }}-openem-scicat-mock
on:
push:
branches: [ $default-branch ]
pull_request:
workflow_dispatch:
jobs:
detect_changes:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
backend: ${{ steps.filter.outputs.backend }}
steps:
# For pull requests it's not necessary to checkout the code
- uses: actions/checkout@v4
if: github.event_name != 'pull_request'
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
backend:
- 'backend/**'
test_backend:
runs-on: ubuntu-latest
needs: detect_changes
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies and run tests
working-directory: ./backend
run: |
python -m pip install --upgrade pip
python -m pip install pipenv
pipenv install
pipenv install pytest-cov
pipenv run pytest archiver --junitxml=junit/test-results.xml --cov=. --cov-report=xml --cov-report=html -m "not endtoend"
- name: Upload pytest test results
uses: actions/upload-artifact@v4
with:
name: backend-test-results
path: ./backend/junit/test-results.xml
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
build_flows_image:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
needs: test_backend
if: ${{ needs.detect_changes.outputs.backend == 'true' }} || github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v3
- name: Log into registry ${{ env.REGISTRY }}
# if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.OPENEM_FLOWS_IMAGE_NAME }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: ./backend
file: ./backend/prefect-flows.Dockerfile
push: true # ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build_config_image:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
needs: test_backend
if: ${{ needs.detect_changes.outputs.backend == 'true' }} || github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v3
- name: Log into registry ${{ env.REGISTRY }}
# if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.OPENEM_CONFIG_IMAGE_NAME }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push
uses: docker/bake-action@v5
with:
workdir: ./backend
files: ./backend/prefect-config.Dockerfile
push: true # ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
build_openem_backend:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
needs: test_backend
if: ${{ needs.detect_changes.outputs.backend == 'true' }} || github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v3
- name: Log into registry ${{ env.REGISTRY }}
# if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.OPENEM_BACKEND_IMAGE_NAME }}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: ./backend
file: ./backend/web.Dockerfile
push: true # ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build_scicat_mock:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
needs: detect_changes
if: ${{ needs.detect_changes.outputs.backend == 'true' }} || github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v3
- name: Log into registry ${{ env.REGISTRY }}
# if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.SCICAT_MOCK_IMAGE_NAME }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: ./backend
file: ./backend/scicatmock.Dockerfile
push: true # ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}