.github/workflows/build-ondemand.yml
name: Build and push containers on demand
on:
workflow_dispatch:
inputs:
service:
description: 'Service container(s) to build'
required: true
default: 'All'
type: choice
options:
- All
- Rails/Sidekiq
- Fedora Commons Repository
- Solr
- FITS Servlet
environment:
description: 'Container repository environment'
required: true
default: 'both'
type: choice
options:
- Both
- Stage
- Production
skip_tests:
description: Build containers without tests
required: true
default: false
type: boolean
permissions:
checks: write
jobs:
lint_and_test:
name: Lint + Test
if: ${{ inputs.skip_tests == false }}
uses: ./.github/workflows/lint-and-test.yml
translate_inputs:
runs-on: ubuntu-latest
outputs:
containers: ${{ steps.container_choices.outputs.containers }}
environments: ${{ steps.environment_choices.outputs.environments }}
tag: ${{ steps.tag_name.outputs.tag }}
steps:
-
id: container_choices
shell: bash
env:
CONTAINER_CHOICE: ${{ inputs.service }}
run: |
output_txt=''
case "${CONTAINER_CHOICE}" in
"All")
output_txt='containers=["rails","sidekiq","fcrepo","solr","fits_servlet"]'
;;
"Rails/Sidekiq")
output_txt='containers=["rails","sidekiq","fits_servlet"]'
;;
"Solr")
output_txt='containers=["solr"]'
;;
"Fedora Commons Repository")
output_txt='containers=["fcrepo"]'
;;
"FITS Servlet")
output_txt='containers=["fits_servlet"]'
;;
esac
echo "$output_txt" >> "$GITHUB_OUTPUT"
-
id: environment_choices
shell: bash
env:
ENVIRONMENT_CHOICE: ${{ inputs.environment }}
run: |
output_txt=''
case "${ENVIRONMENT_CHOICE}" in
"Both")
output_txt='environments=["stage","production"]'
;;
"Stage")
output_txt='environments=["stage"]'
;;
"Production")
output_txt='environments=["production"]'
;;
esac
echo "$output_txt" >> "$GITHUB_OUTPUT"
-
id: tag_name
env:
BRANCH_NAME: ${{ github.ref_name }}
run: echo "tag=$BRANCH_NAME" >> "${GITHUB_OUTPUT}"
build_containers:
name: Build Containers
uses: ./.github/workflows/build-containers.yml
needs: [lint_and_test,translate_inputs]
with:
registry: ${{ secrets.CONTAINER_REGISTRY }}
username: ${{ secrets.CONTAINER_REGISTRY_USERNAME }}
password: ${{ secrets.CONTAINER_REGISTRY_TOKEN }}
tag: ${{ needs.translate_inputs.outputs.tag }}
services: ${{ toJson(needs.translate_inputs.outputs.containers) }}
environments: ${{ toJson(needs.translate_inputs.outputs.environments )}}