make manifest to group tags #14
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: Build and Push Docker Image (Test Workflow) | |
# Run on push to branches other than main | |
on: | |
push: | |
branches-ignore: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest # Only build on Ubuntu for now since Docker is not available on macOS runners | |
strategy: | |
matrix: | |
platform: [linux/amd64] # Only build amd64 for now | |
max-parallel: 2 # Build both architectures in parallel (if more than one) | |
outputs: | |
git_sha: ${{ steps.get_sha.outputs.sha }} | |
sanitized_platform: ${{ steps.sanitize_platform.outputs.sanitized_platform }} | |
steps: | |
- name: Checkout code | |
# https://github.com/actions/checkout | |
uses: actions/checkout@v4 | |
- name: Get Git SHA | |
id: get_sha | |
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
- name: Debug Git SHA | |
run: echo "Git SHA ${{ steps.get_sha.outputs.sha }}" | |
# Generate a sanitized platform string with slashes replaced by dashes | |
- name: Sanitize platform name | |
id: sanitize_platform | |
run: | | |
sanitized_platform="${{ matrix.platform }}" # Copy platform value | |
sanitized_platform="${sanitized_platform/\//-}" # Replace / with - | |
echo "sanitized_platform=$sanitized_platform" >> $GITHUB_OUTPUT | |
- name: Set up Docker Buildx | |
# https://github.com/docker/setup-buildx-action | |
uses: docker/setup-buildx-action@v3 | |
with: | |
driver: docker-container # Use a container driver for Buildx (default) | |
- name: Log in to Docker Hub | |
# https://github.com/docker/login-action | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ vars.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push Docker image | |
# https://github.com/docker/build-push-action | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./docker # Build context | |
file: ./docker/Dockerfile # Path to Dockerfile | |
platforms: ${{ matrix.platform }} | |
push: true # Push the image to Docker Hub | |
# Tags all include "-test" to differentiate from production images | |
tags: | | |
${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:${{ steps.sanitize_platform.outputs.sanitized_platform }}-test | |
${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:${{ steps.sanitize_platform.outputs.sanitized_platform }}-nvidia-cuda-11.3.1-cudnn8-runtime-ubuntu20.04-test | |
${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:${{ steps.sanitize_platform.outputs.sanitized_platform }}-sleap-1.3.4-test | |
${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:${{ steps.sanitize_platform.outputs.sanitized_platform }}-${{ steps.get_sha.outputs.sha }}-test | |
consolidate: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Log in to Docker Hub | |
# https://github.com/docker/login-action | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ vars.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
# This makes it easier to pull the latest test image | |
- name: Create and push consolidated manifest | |
run: | | |
docker manifest create ${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:test \ | |
${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:linux-amd64-test \ | |
${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:linux-amd64-nvidia-cuda-11.3.1-cudnn8-runtime-ubuntu20.04-test \ | |
${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:linux-amd64-sleap-1.3.4-test \ | |
${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:linux-amd64-${{ needs.build.outputs.git_sha }}-test | |
docker manifest push ${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:test |