0.21.3 #225
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: Publish Docker images on GHCR | |
env: | |
REGISTRY: ghcr.io/Substra | |
on: | |
release: | |
types: [published] | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
cuda_images: | |
description: 'cuda_images. Example: ["nvidia/cuda:11.6.0-base-ubuntu20.04"]' | |
required: true | |
python_versions: | |
description: 'python_versions. Example: ["3.8", "3.9"]' | |
required: true | |
release_tag: | |
description: "release_tag. Example: 0.9.1" | |
required: true | |
jobs: | |
create-matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
# Add a version to this list to automatically build Dockerfiles from it for the next releases | |
default_cuda_images: '["nvidia/cuda:11.8.0-base-ubuntu22.04"]' | |
default_python_versions: '["3.9", "3.10", "3.11"]' | |
steps: | |
- run: true | |
build: | |
needs: create-matrix | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false # don't stop all the builds if one fails | |
matrix: | |
cuda_image: ${{ github.event_name == 'workflow_dispatch' && fromJson(github.event.inputs.cuda_images) || fromJson(needs.create-matrix.outputs.default_cuda_images) }} | |
python_version: ${{ github.event_name == 'workflow_dispatch' && fromJson(github.event.inputs.python_versions) || fromJson(needs.create-matrix.outputs.default_python_versions) }} | |
steps: | |
- name: Set variables | |
run: | | |
SUBSTRA_TOOLS_REF=$(echo "${{ github.event.inputs.release_tag || github.ref_name }}" | tr -d ':,/') | |
CUDA_IMAGE_TAG=$(echo "${{ matrix.cuda_image }}" | tr -d ':,/') | |
if [ $SUBSTRA_TOOLS_REF = "main" ]; then | |
echo "IMG_BASE_TAG=latest-$CUDA_IMAGE_TAG-python${{ matrix.python_version }}" >> $GITHUB_ENV | |
# Set the most recent image to latest | |
if [ "${{ matrix.cuda_image }}" == "nvidia/cuda:11.8.0-base-ubuntu22.04" ] && [ "${{ matrix.python_version }}" == "3.11" ]; then | |
echo "LATEST_TAG=latest" >> $GITHUB_ENV | |
fi | |
else | |
echo "IMG_BASE_TAG=$SUBSTRA_TOOLS_REF-$CUDA_IMAGE_TAG-python${{ matrix.python_version }}" >> $GITHUB_ENV | |
fi | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.inputs.release_tag || github.ref }} | |
- name: Login to GHCR | |
uses: docker/login-action@v1 | |
if: ${{ github.event_name != 'pull_request' }} | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker default image metadata | |
id: default-metadata | |
uses: docker/metadata-action@v3 | |
with: | |
images: "${{ env.REGISTRY }}/substra-tools" | |
tags: | | |
${{ env.IMG_BASE_TAG }} | |
${{ env.LATEST_TAG }} | |
- name: Build and Push default image | |
uses: docker/build-push-action@v2 | |
with: | |
push: ${{ github.event_name != 'pull_request' }} | |
file: Dockerfile | |
context: . | |
tags: ${{ steps.default-metadata.outputs.tags }} | |
labels: ${{ steps.default-metadata.outputs.labels }} | |
build-args: | | |
CUDA_IMAGE=${{ matrix.cuda_image }} | |
PYTHON_VERSION=${{ matrix.python_version }} |