.github/workflows/build-containers.yml
name: Build containers
on:
workflow_call:
secrets:
username:
required: true
description: "Username value for container repository"
password:
required: true
description: "Password/token value for container repository"
registry:
required: false
description: "URL for container repository (default: DockerHub)"
inputs:
tag:
type: string
required: true
description: "Version identifier for release"
services:
type: string
required: true
description: "Stringified JSON array of which service containers to build"
default: '["rails","sidekiq","fcrepo","solr","fits_servlet"]'
environments:
type: string
required: true
description: Stringified JSON array of GitHub environments to use for variables
default: '["stage","production"]'
jobs:
build_containers:
name: Build containers
runs-on: ubuntu-latest
environment: ${{ matrix.environment }}
strategy:
matrix:
environment: ${{ fromJson(inputs.environments) }}
service:
-
name: rails
image: lafayette/rails
context: .
target: spot-web-production
-
name: sidekiq
image: lafayette/sidekiq
context: .
target: spot-worker-production
-
name: solr
image: lafayette/solr
context: ./docker/solr
-
name: fcrepo
image: lafayette/fc
context: ./docker/fcrepo
-
name: fits_servlet
image: lafayette/fits_servlet
context: ./docker/fits_servlet
steps:
- uses: actions/checkout@v4
-
name: Log into Docker
uses: docker/login-action@v2
with:
registry: ${{ secrets.registry || 'docker.io' }}
username: ${{ secrets.username }}
password: ${{ secrets.password }}
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Build and push ${{ matrix.service.image }} container
uses: ./.github/actions/build-container
if: ${{ contains(fromJson(inputs.services), matrix.service.name) }}
with:
registry: ${{ secrets.registry || 'docker.io' }}
tag: ${{ inputs.tag }}
image_name: ${{ matrix.service.image }}
context: ${{ matrix.service.context }}
target: ${{ matrix.service.target }}