Skip to content

Add ci

Add ci #2

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 || secrets.DOCKERHUB_USERNAME }}"
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 and push image
uses: docker/build-push-action@v6
with:
context: .
file: ${{ env.DOCKERFILE_PATH }}
target: ${{ env.DOCKER_TARGET }}
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' && github.ref_type == 'tag' }}
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 }}