Publish Docker Images #35
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: ui-tio | |
build-dir: modules/front-end | |
file: ./Dockerfile | |
- app: api-tio | |
build-dir: modules/back-end | |
file: ./deploy/Dockerfile | |
- app: da-server-tio | |
build-dir: modules/data-analytics | |
file: ./Dockerfile | |
- app: evaluation-server-tio | |
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 | |
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 | |
push: true | |
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ matrix.app }}:${{ env.LATEST_TAG }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |