Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: Docker Publish

on:
push:
tags:
- "v*"
pull_request:
workflow_dispatch:

env:
IMAGE_NAME: scop3p-toolkit
DOCKERFILE_PATH: docker/Dockerfile
DOCKER_TARGET: scop3p-toolkit
PYTHON_VERSION: "3.12"

jobs:
test:
name: Pytest suite
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements-biophysics.txt
python -m pip install -r requirements-shiny.txt
python -m pip install pytest

- name: Run tests
run: pytest tests/unit tests/integration

docker:
name: Build and publish Docker image
runs-on: ubuntu-latest
needs: test
permissions:
contents: read

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Prepare image variables
id: vars
shell: bash
run: |
namespace="${{ vars.DOCKERHUB_NAMESPACE }}"
if [[ -z "${namespace}" ]]; then
namespace="${{ secrets.DOCKERHUB_USERNAME }}"
fi
if [[ -z "${namespace}" ]]; then
namespace="${GITHUB_REPOSITORY_OWNER,,}"
fi
version="${GITHUB_SHA}"
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
version="${GITHUB_REF_NAME}"
fi
{
echo "image_repository=${namespace}/${IMAGE_NAME}"
echo "build_date=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
echo "version=${version}"
} >> "${GITHUB_OUTPUT}"

- name: Log in to Docker Hub
if: github.event_name != 'pull_request' && github.ref_type == 'tag'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: docker.io/${{ steps.vars.outputs.image_repository }}
tags: |
type=raw,value=latest,enable=${{ github.ref_type == 'tag' }}
type=sha,format=short,prefix=sha-
type=ref,event=tag
labels: |
org.opencontainers.image.title=Scop3P-Toolkit
org.opencontainers.image.description=Scop3P toolkit container for Galaxy interactive tool deployment
org.opencontainers.image.licenses=Apache-2.0

- name: Build image
if: github.ref_type != 'tag'
uses: docker/build-push-action@v6
with:
context: .
file: ${{ env.DOCKERFILE_PATH }}
target: ${{ env.DOCKER_TARGET }}
platforms: linux/amd64
push: false
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_DATE=${{ steps.vars.outputs.build_date }}
VCS_REF=${{ github.sha }}
VERSION=${{ steps.vars.outputs.version }}

- name: Build and push image
if: github.ref_type == 'tag'
uses: docker/build-push-action@v6
with:
context: .
file: ${{ env.DOCKERFILE_PATH }}
target: ${{ env.DOCKER_TARGET }}
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_DATE=${{ steps.vars.outputs.build_date }}
VCS_REF=${{ github.sha }}
VERSION=${{ steps.vars.outputs.version }}
Loading
Loading