Skip to content

Publish Docker Images #85

Publish Docker Images

Publish Docker Images #85

name: Publish Docker Images
on:
workflow_dispatch:
inputs:
version:
description: "Image version (For example: 1.0.0)"
required: true
build-latest:
description: "Build and publish latest image"
type: boolean
default: false
required: false
debug:
description: "Debug mode"
type: boolean
default: false
required: false
env:
LATEST_TAG: latest
VERSION_TAG: ${{ github.event.inputs.version }}
jobs:
build-publish:
name: Build and publish image to Docker Hub
runs-on: ubuntu-latest
environment: Production
strategy:
matrix:
include:
- app: featbit-ui
build-dir: modules/front-end
file: ./Dockerfile
- app: featbit-api-server
build-dir: modules/back-end
file: ./deploy/Dockerfile
- app: featbit-data-analytics-server
build-dir: modules/data-analytics
file: ./Dockerfile
- app: featbit-evaluation-server
build-dir: modules/evaluation-server
file: ./deploy/Dockerfile
steps:
- name: Dump GitHub context (run if debug is true)
if: ${{ github.event.inputs.debug == 'true' }}
run: echo "${{ toJson(github) }}"
- name: Normal (run if debug is true)
if: ${{ github.event.inputs.debug == 'true' }}
run: echo "debug is true"
- name: Conditional (run if debug and build-latest is true)
if: ${{ github.event.inputs.debug == 'true' && github.event.inputs.build-latest == 'true' }}
run: echo "debug and build-latest is true"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- 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_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build and push - ${{ matrix.app }} (${{ env.VERSION_TAG }})
uses: docker/build-push-action@v5
with:
context: "{{defaultContext}}:${{ matrix.build-dir }}"
file: ${{ matrix.file }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ matrix.app }}:${{ env.VERSION_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push - ${{ matrix.app }} (${{ env.LATEST_TAG }})
if: ${{ github.event.inputs.build-latest == 'true' }}
uses: docker/build-push-action@v5
with:
context: "{{defaultContext}}:${{ matrix.build-dir }}"
file: ${{ matrix.file }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ matrix.app }}:${{ env.LATEST_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max