Skip to content

Publish Docker Images #26

Publish Docker Images

Publish Docker Images #26

name: Publish Docker Images
on:
workflow_dispatch:
workflow_run:
workflows: [Upload Python Package]
types: [completed]
jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Extract and transform version from pyproject.toml
id: extract_version
run: |
VERSION=$(grep -m 1 version ./pyproject.toml | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3)
# Replace "-alpha" with "a0", "-beta" with "b0", and so on
DOCKER_VERSION=$(echo $VERSION | sed 's/-alpha/a0/' | sed 's/-beta/b0/' | sed 's/-rc/rc0/')
echo "DOCKER_VERSION=$DOCKER_VERSION" >> $GITHUB_ENV
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./Dockerfile
push: true
tags: |
mistmedical/mist:${{ env.DOCKER_VERSION }}
mistmedical/mist:latest