Skip to content

Build and push image to Docker Hub #4

Build and push image to Docker Hub

Build and push image to Docker Hub #4

Workflow file for this run

name: Build and push image to Docker Hub
on:
workflow_dispatch:
inputs:
release_version:
description: "Release version. Eg: 0.0.11"
required: false
type: string
default: ''
env:
platforms: "linux/amd64,linux/arm64/v8"
jobs:
build-image:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set Docker meta for multi-arch image
id: set_metadata
uses: docker/metadata-action@v5
with:
images: |
${{ vars.DOCKERHUB_ORG }}/${{ vars.DOCKERHUB_REPO }}
tags: |
type=raw,prefix={{branch}}-,value={{sha}},enable=${{ inputs.release_version == '' && github.event_name == 'workflow_dispatch' }}
type=raw,value=${{ inputs.release_version }},enable=${{ inputs.release_version != '' && github.event_name == 'workflow_dispatch' }}
type=raw,value={{tag}},event=tag
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
platforms: ${{ env.platforms }}
push: false
labels: ${{ steps.set_metadata.outputs.labels }}
tags: ${{ steps.set_metadata.outputs.tags }}