Skip to content

Build & Publish to Docker Hub from Tag #4

Build & Publish to Docker Hub from Tag

Build & Publish to Docker Hub from Tag #4

name: Build & Publish to Docker Hub from Tag
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag from which build images'
type: string
required: true
workflow_call:
inputs:
tag:
description: 'Tag from which build images'
type: string
required: true
permissions:
contents: write
pull-requests: write
jobs:
docker-build-push:
name: Build & Publish ${{ matrix.docker.name }} to Docker Hub
strategy:
matrix:
docker:
- { name: Hiker's Book UI, target: ui-hikers-book, image: radoslavirha/hikers-book-ui-hikers-book }
- { name: Authentication API, target: api-authentication, image: radoslavirha/hikers-book-api-authentication }
- { name: GraphQL API, target: api-graphql, image: radoslavirha/hikers-book-api-graphql }
- { name: Stages API, target: api-stages, image: radoslavirha/hikers-book-api-stages }
- { name: Trips API, target: api-trips, image: radoslavirha/hikers-book-api-trips }
runs-on: ubuntu-latest
steps:
- name: Show github.event.inputs.tag
run: echo ${{ github.event.inputs.tag }}
- name: Show inputs.tag
run: echo ${{ inputs.tag }}
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag }}
- 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.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./infra/docker/Dockerfile
# platforms: linux/amd64,linux/arm64
push: true
tags: ${{ matrix.docker.image }}:${{ github.event.inputs.tag }},${{ matrix.docker.image }}:latest
target: ${{ matrix.docker.target }}