Skip to content

Build and publish Docker image #809

Build and publish Docker image

Build and publish Docker image #809

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@v3
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v4
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: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push ARM
uses: docker/build-push-action@v4
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@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
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