Build and publish Docker image #968
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 publish Docker image' | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Enter an image tag e.g v0.1.0' | |
required: true | |
repo_type: | |
description: 'Choose repository type' | |
type: choice | |
required: false | |
default: 'non-official' | |
options: | |
- official | |
- non-official | |
jobs: | |
build_and_push_docker_image_amd: | |
if: github.repository_owner == 'NethermindEth' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
platforms: 'linux/amd64' | |
push: true | |
tags: nethermindeth/juno:${{ github.event.inputs.tag }} | |
build_and_push_docker_image_arm: | |
if: github.repository_owner == 'NethermindEth' | |
runs-on: ubuntu-arm64-4-core | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push ARM | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
platforms: 'linux/arm64' | |
push: true | |
tags: nethermindeth/juno:${{ github.event.inputs.tag }}-arm64 | |
- name: Cleanup self-hosted | |
run: | | |
docker system prune -af | |
create_and_push_official_image: | |
if: github.repository_owner == 'NethermindEth' && github.event.inputs.repo_type == 'official' | |
needs: [build_and_push_docker_image_amd, build_and_push_docker_image_arm] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Create and push manifest using buildx | |
run: | | |
docker buildx imagetools create nethermindeth/juno:${{ github.event.inputs.tag }} \ | |
nethermindeth/juno:${{ github.event.inputs.tag }}-arm64 \ | |
--tag nethermind/juno:${{ github.event.inputs.tag }} | |
- name: Clean up environment | |
if: always() | |
run: | | |
rm -f ${HOME}/.docker/config.json | |