Skip to content

Build and push image to Docker Hub #5

Build and push image to Docker Hub

Build and push image to Docker Hub #5

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/arm/v7,linux/arm64"
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: |
drag0nfire19/${{ 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 }}