Build CI images #20
Workflow file for this run
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
# | |
# This workflow builds Docker images for Linux CI builds. | |
# | |
name: Build CI images | |
on: | |
workflow_dispatch: | |
inputs: | |
# | |
# Any unique sequence of characters would work as a CI build image | |
# tag, but an ISO-8601 date without separators would be the easiest | |
# to maintain. In a rare case when more than one image needs to | |
# be built in one day, a sequence suffix may be added: 20220526.1 | |
# | |
CI_BLD_IMG_TAG: | |
description: CI build image tag (e.g. 20220526) | |
required: true | |
env: | |
# | |
# ghcr.io requires owner to be in lowercase, so we can't use | |
# ${{ github.actor }}, which may have mixed case characters. | |
# | |
CI_BLD_IMG_REG: ghcr.io | |
CI_BLD_IMG_OWNER: stonestepsinc | |
jobs: | |
build-ci-images: | |
name: Build CI images | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
linux-flavor: | |
- fedora | |
- ubuntu | |
env: | |
# | |
# Use slashes to separate Linux flavor from the image name, which | |
# is allowed in many private registries, including GitHub and Azure, | |
# but not in Docker Hub. | |
# | |
# {0} {1} | |
# ghcr.io/stonestepsinc/fit/ubuntu:20220526 | |
# | |
# In Azure DevOps, this would just be the variable CI_BLD_IMG_NAME | |
# defined, but `env` mappings cannot be used in this context, so | |
# we can either create prefix/suffix strings to combine all bits | |
# later or use a format, so at least it is clear where goes what. | |
# | |
CI_BLD_IMG_NAME_FMT: '{0}/{1}/fit/${{ matrix.linux-flavor }}:${{ github.event.inputs.CI_BLD_IMG_TAG }}' | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v3 | |
# use the command line to build an image, which is more descriptive than the action | |
- name: Build ${{ matrix.linux-flavor }} image | |
run: | | |
docker build --file devops/Dockerfile.${{ matrix.linux-flavor }} --tag ${{ format(env.CI_BLD_IMG_NAME_FMT, env.CI_BLD_IMG_REG, env.CI_BLD_IMG_OWNER) }} devops | |
- name: Docker login | |
uses: docker/login-action@v2.0.0 | |
with: | |
registry: ${{ env.CI_BLD_IMG_REG }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push ${{ matrix.linux-flavor }} image | |
run: | | |
docker push ${{ format(env.CI_BLD_IMG_NAME_FMT, env.CI_BLD_IMG_REG, env.CI_BLD_IMG_OWNER) }} |