Skip to content
name: Build docker image & push to registry.
on:
workflow_call:
inputs:
docker_registry:
description: Docker registry
required: false
default: 'ghcr.io'
type: string
registry_org:
description: Docker registry organisation
required: false
default: 'ministryofjustice'
type: string
additional_docker_tag:
description: Additional docker tag that can be used to specify stable tags
required: false
default: ''
type: string
push:
description: Push docker image to registry flag
required: true
default: true
type: boolean
permissions:
contents: read
packages: write
jobs:
docker_build:
name: Build docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set version
id: version
run: |
version=$(date '+%Y-%m-%d').${{ github.run_number }}.$(echo ${{ github.sha }} | cut -c1-7)
echo "version=$version" | tee -a "$GITHUB_OUTPUT"
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2

Check failure on line 44 in .github/workflows/test_docker_build.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/test_docker_build.yml

Invalid workflow file

You have an error in your yaml syntax on line 44
- name: Docker login if Docker registry is quay.io
if: "${{ inputs.docker_registry }}" == "quay.io"
uses: docker/login-action@v2
with:
registry: ${{ inputs.docker_registry }}
username: ${{ secrets.HMPPS_QUAYIO_USER }}
password: ${{ secrets.HMPPS_QUAYIO_TOKEN }}
- name: Docker login if Docker registry is ghcr.io
if: "${{ inputs.docker_registry }}" == "ghcr.io"
uses: docker/login-action@v2
with:
registry: ${{ inputs.docker_registry }}
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build Docker images
uses: docker/build-push-action@v4
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
push: ${{ inputs.push }}
provenance: false
tags: |
${{ inputs.docker_registry}}/${{ inputs.registry_org }}/${{ github.event.repository.name }}:latest
${{ inputs.docker_registry}}/${{ inputs.registry_org }}/${{ github.event.repository.name }}:${{ steps.version.outputs.version }}