Skip to content

Publish Docker Images #1

Publish Docker Images

Publish Docker Images #1

name: "Publish Docker Images"
on:
workflow_dispatch:
inputs:
version:
description: 'Version tag (e.g., v1.0.0)'
required: true
specific_image:
description: 'Build only this image [madara, orchestrator, bootstrapper, pathfinder, helper] (leave empty to build all images)'
required: false
default: ''
env:
DOCKER_ORGANIZATION: mslmadara
jobs:
build_docker_images:
runs-on: [self-hosted, docker_image_builder]
strategy:
matrix:
image: ${{ github.event.inputs.specific_image == '' && fromJSON('["helper", "bootstrapper", "madara", "orchestrator", "pathfinder"]') || fromJSON(format('["{0}"]', github.event.inputs.specific_image)) }}
# Set fail-fast to false to prevent cancellation of other jobs
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set image name from input
id: image_name
run: echo "name=${{ github.event.inputs.image_name }}" >> $GITHUB_OUTPUT
- name: Set organization name
id: org_name
run: echo "org=${{ github.event.inputs.organization }}" >> $GITHUB_OUTPUT
- name: Git commit hash
id: hash
run: echo "hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Build and push the image
- name: Build and push image
uses: docker/build-push-action@v4
with:
context: deps/${{ matrix.image }}
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.DOCKER_ORGANIZATION }}/${{ matrix.image }}:latest
${{ env.DOCKER_ORGANIZATION }}/${{ matrix.image }}:${{ github.event.inputs.version }}-${{ steps.hash.outputs.hash }}
ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}:latest
ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}:${{ github.event.inputs.version }}-${{ steps.hash.outputs.hash }}
continue-on-error: false