set-output is deprecated #2
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 Multi-Arch Docker Image (Test Workflow) | ||
# Run on push to branches other than main | ||
on: | ||
push: | ||
branches-ignore: | ||
- main | ||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [macos-latest, ubuntu-latest] # Use macOS for ARM64 and Ubuntu for AMD64 | ||
platform: [linux/arm64, linux/amd64] # Build for both architectures | ||
max-parallel: 2 # Build both architectures in parallel | ||
outputs: | ||
git_sha: ${{ steps.get_sha.outputs.sha }} | ||
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 }}" | ||
- name: Set up Docker Buildx | ||
# https://github.com/docker/setup-buildx-action | ||
uses: docker/setup-buildx-action@v3 | ||
- 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: | | ||
${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:${{ matrix.platform }}-test | ||
${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:${{ matrix.platform }}-nvidia-cuda-11.3.1-cudnn8-runtime-ubuntu20.04-test | ||
${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:${{ matrix.platform }}-sleap-1.3.4-test | ||
${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:${{ matrix.platform }}-${{ steps.get_sha.outputs.sha }}-test | ||
- name: Clean up Docker resources | ||
run: docker system prune -af | ||
combine-manifest: | ||
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 }} | ||
- name: Create multi-arch manifest | ||
run: | | ||
# Create a multi-arch manifest for the test tag | ||
docker manifest create ${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:test \ | ||
${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:linux/amd64-test \ | ||
${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:linux/arm64-test | ||
docker manifest push ${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:test | ||
- name: Push additional multi-arch tags | ||
run: | | ||
# Multi-arch manifest for CUDA version | ||
docker manifest create ${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:nvidia-cuda-11.3.1-cudnn8-runtime-ubuntu20.04-test \ | ||
${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:linux/amd64-test \ | ||
${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:linux/arm64-test | ||
# Multi-arch manifest for SLEAP version | ||
docker manifest create ${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:sleap-1.3.4-test \ | ||
${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:linux/amd64-test \ | ||
${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:linux/arm64-test | ||
# Multi-arch manifest for Git SHA | ||
docker manifest create ${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:${{ needs.build.outputs.git_sha }}-test \ | ||
${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:linux/amd64-test \ | ||
${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:linux/arm64-test | ||
docker manifest push ${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:nvidia-cuda-11.3.1-cudnn8-runtime-ubuntu20.04-test | ||
docker manifest push ${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:sleap-1.3.4-test | ||
docker manifest push ${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:${{ needs.build.outputs.git_sha }}-test | ||
- name: Inspect multi-arch manifest | ||
run: | | ||
docker manifest inspect ${{ vars.DOCKERHUB_USERNAME }}/sleap-cuda:test |