Build and dispatch workflows#
This feature is a collection of seven workflows (along with their configuration files), which when used in conjunction allow an user to build final docker images from a release tag, or snapshot images, from a pre-release tag, or commit SHA; Once the images are built, the make_dispatches workflow dispatch the image update automatically to their respective state repositories. They can be thought of as two different but closely related features.
The workflows trigger_dispatch_on_releases.yaml, trigger_dispatch_on_pre-releases.yaml and trigger_dispatch_on_snapshot.yaml only serve to trigger make_dispatches.yaml after a successful automated call to any of the build_docker_<type>.yaml workflows. They require no other explanation so they won’t be discussed in this README
Build images#
Composed of the workflows .github/workflows/build_docker_releases.yaml, .github/workflows/build_docker_pre-releases.yaml and .github/workflows/build_docker_snapshots.yaml.
Configuration#
All build workflows use the same configuration file located at .github/build_images.yaml. Its format is as follows:
snapshots: # Configuration specific for snapshots, used by build_docker_pre-releases and build_docker_snapshots
flavor: # Flavor-specific configuration. A flavor can be named anything as long as it's a valid YAML key
dockerfile: path/to/dockerfile # Path relative to the repo root folder
auto: false # Whether or not to automatically build this flavor when the * input is specified (see "Inputs" below). Defaults to false
build_args: # Enviroment variables to set during the image building process
# ENV_VARIABLE_NAME: env_variable_value
API_URL: https://api.com/url
UI_COLOR: '#125690'
extra_registries: # List of registries, other than the default one (see "Defaults" below), where to upload the image
- name: registry.azure.io
repository: service/repo
auth_strategy: azure_oidc
# Multiple kinds of registries can be specified
- name: aws.amazon.com
repository: programs/program-name # Repository names can be different between registries
auth_strategy: aws_oidc # Multiple auth strategies should be supported but they currently aren't
another-flavor:
dockerfile: path/to/dockerfile
registry: # The default registry can be overriden (see "Defaults" below)
name: nondefault.registry.es
repository: nondefault/repo
auth_strategy: azure_oidc # Can be any of azure_oidc or aws_oidc
releases: # Configuration specific for releases, used by build_docker_releases
release-flavor:
... # The same configuration parameters as snapshots can be used heresnapshots: all image flavors included within this key will count as a snapshot flavor, and thus will be built when thebuild_docker_snapshotsorbuild_docker_pre-releasesworkflows are executedreleases: all image flavors included within this key will count as a release flavor, and thus will be built when thebuild_docker_releasesworkflow is executed
Inside each of these two keys (type keys) there will be one or more flavor keys:
<flavor>: the name of the flavor to build. Will be appended to the end of the final image tag. The same flavor name cannot be duplicated inside the sametypekey, but it can be in bothtypekeys at the same time (i.e.snapshotscannot contain twodefaultflavor keys, but bothsnapshotsandreleasescan contain a singledefaultkey at the same time)
Each flavor key can contain:
dockerfile: path to the dockerfile to use when building this image, relative to the repo root (i.e. if the dockerfile is located athttps://www.github.com/firestartr-test/code-repo/docker/Dockerfile, this keys’ value will bedocker/Dockerfile)auto: whether or not to build this flavor when theflavorsinput equals *. Defaults to falsebuild_args: key-value pairs that are set as environment variables when building the image. The key is the environment value name, and the value its value, and any number of them can be specified.registry: aregistryobject that overrides the default registry. If this key is specified, no image will be uploaded to the default registryextra_registries: a list ofregistryobject to where the image will be uploaded to, in addition to the default registry. If this key is specified, the image will still be uploaded to the default registry
Registry objects#
A registry object contains the following keys:
name: base URL of the registry. E.g. when uploading a image toregistry.com/image_repo/image_tag, this key’s value should beregistry.comrepository: name of the repository inside of the registrynameto where upload the image to. E.g. when uploading a image toregistry.com/image_repo/image_tag, this key’s value should beimage_repoauth_strategy: type of authentication to use for login, as different registries require different authentication methods. Though many are defined, currently onlyaz_oidcandaws_oidcare supported
Inputs#
All build workflows use the same inputs. They are:
from: point of the code history from which the image will be built. Can be a short or long commit SHA, a branch name or a tag nameflavors: which flavors to build. Each workflow will only look for flavors in their respective section (i.e., build_docker_releases will only build flavors fromreleases, while the other two will only build flavors fromsnapshots). Can be a single flavor, a list of comma separated flavors (spaces are trimmed) or *. * builds all flavors that are set as auto inbuild_images.yaml(see Configuration)
Defaults#
All build workflows use the same defaults. There are two types of defaults: environment variables and defaults defined by code. The environment variables are:
DOCKER_REGISTRY_RELEASES: base URL of the Docker registry for releases. Follows the same format asextra_registries.nameandregistry.name(e.g.prefapp.azureacr.io. See Configuration)DOCKER_REGISTRY_SNAPSHOTS: base URL of the Docker registry for snapshots. Follows the same format asextra_registries.nameandregistry.name(e.g.prefapp.azureacr.io. See Configuration)
The defaults defined by code are:
registry.repositorydefaults to the name of the repo the workflow is being executed on, including the owner. E.g.prefapp/test-repo-rundaggerflavor.autodefaults tofalse
Make dispatches#
Composed of the workflow .github/workflows/make_dispatches.yaml.
Configuration#
The make_dispatches workflow uses the configuration file located at .github/make_dispatches.yaml. Its format is as follows:
deployments: # Has a list of configurations
- tenant: prefapp
platform: az-cluster # Platform where we want to dispatch changes to
type: snapshots # Either snapshots or releases
flavor: flavor1 # Flavor to dispatch for this deployment. Must have the same name as a flavor defined in build_images.yaml, under the chosen type (see "Build images -> Configuration" above)
version: $branch_dev # See "About the version field" below
registry: prefapp.azureacr.io # Optional. Registry where the image was uploaded to (see "Defaults" below)
image_repository: service/test-repo # Optional. Repo where the image was uploaded to (see "Defaults" below)
base_path: apps # Can be left empty or unspecified
application: test-repo-rundagger
env: dev
# You can specify one of the following
service_names: ['test-repo-service'] # List, multiple services can be specified
# OR
image_keys: ['/test-repo-service/image'] # List, multiple image keys can be specified
# So, in this example github.com/prefapp/prefapp-state/apps/<platform-type>/az-cluster/prefapp/test-repo-rundagger/dev would be updated when making this dispatch
# An entry is created for each tenant - platform - type - flavor combination we want to dispatch
- tenant: prefapp
platform: az-cluster
type: snapshots
flavor: another-flavor
...
- tenant: prefapp
platform: aks-cluster
type: snapshots
flavor: flavor1
...deployments: contains the list of deployments to dispatch. Has no special data or meaning but must be specified for the dispatch workflow to work
Each deployment contains:
tenant: name of the tenant that will be used for this deployment. Used to determine which file to update when dispatching, and also for validation: the tenant must be specified in the list of valid tenants in the platform configuration of the.firestartrrepoplatform: name of the platform that will be used for this deployment. Used to determine which file to update when dispatching, and also for validation: the specified platform must have an associated configuration file. From the platform configuration file, it’stypewill also be used when determining which file to update.type: deployment type, can be either ofsnapshotsorreleases. Used when calling the dispatch workflow to filter which dispatches to make.flavor: name of the flavor that will be used for this deployment. Used to compose the image tag, which will be written to the corresponding deployment files and must have been built beforehand.version: version of the code used in the image. Used to compose the image tag, which will be written to the corresponding deployment manifests and must have been built beforehand. See About the version field for more info on the possible values this parameter could have.registry: registry to where the image has been uploaded to. This parameter is optional, and the registry specified in either theDOCKER_REGISTRY_RELEASESandDOCKER_REGISTRY_SNAPSHOTSvariables will be used by default (see Defaults).image_repository: repository to where the image has been uploaded to. This parameter is optional, and the repository specified in the application configuration will be used by default.base_path: legacy parameter. Appends this value to the deployment path, so that the final result ends like:<base_path>/<platform-type>/<platform>/<tenant>/<env>. Should only be used when dispatching to an old state repository.application: name of the application that will be dispatched. Used for validation, as a valid configuration must exist for the application, and to get the default state and image repo.env: environment where to deploy to. Could technically be any string, but usually is one ofdev,preorpro. Must be a value included in theregistryconfiguration file.service_names: names of the services this deployment will be dispatched to. These values will be validated against the application configuration in the.firestartrrepo: each value of this field must be included within theservice_namesof the current repository for this deployment’s application. Cannot be used at the same time as theimage_keysparameter.image_keys: list of JSONPatch paths to patch the deployment YAMLs. These values aren’t validated against any configuration file. Cannot be used at the same time as theservice_namesparameter.
Workflow inputs#
image_type: which types of images to build. Can bereleases,snapshots(default) or*(both)flavors: which flavors to dispatch. Will only look for flavors insideimage_type. Can be a single flavor, a list of comma separated flavors (spaces are trimmed) or*.*builds all flavors that are set as auto inbuild_images.yaml(see Build Images -> Configuration)overwrite_version: instead of usingversion, the value of this input will be used for eachimage_typeandflavorsif specified. Can be any of the validmake_dispatches.yamlconfiguration keywords (see About the version field)overwrite_tenant: instead of usingtenant, the value of this input will be used for eachimage_typeandflavorsif specified.overwrite_env: instead of usingenv, the value of this input will be used for eachimage_typeandflavorsif specified.filter_by_tenant: only dispatch to thetenantspecified by this input. These tenants must already have an entry inmake_dispatches.yamlforimage_typeandflavors(i.e. this filter won’t do anything if theflavorsofimage_typecould not be dispatched tofilter_by_tenantto begin with). Can be a single tenant, a list of comma separated tenants (spaces are trimmed) or*(all tenants for a givenimage_typeandflavors)filter_by_env: only dispatch to theenvspecified by this input. These envs must already have an entry inmake_dispatches.yamlforimage_typeandflavors(i.e. this filter won’t do anything if theflavorsofimage_typecould not be dispatched tofilter_by_envto begin with). Can be a single env, a list of comma separated envs (spaces are trimmed) or*(all envs for a givenimage_typeandflavors)filter_by_platform: only dispatch to theplatformspecified by this input. These platforms must already have an entry inmake_dispatches.yamlforimage_typeandflavors(i.e. this filter won’t do anything if theflavorsofimage_typecould not be dispatched tofilter_by_platformto begin with). Can be a single platform, a list of comma separated platforms (spaces are trimmed) or*(all platforms for a givenimage_typeandflavors)workflow_run_id: the workflow needs the build summary of the lastbuild_docker_<type>. If you have access to it, you can give it as an input here. If left blank, it will be automatically calculated by the workflow
Defaults#
The defaults are defined as environment variables and are:
DOCKER_REGISTRY_RELEASES: base URL of the Docker registry for releases. Follows the same format asextra_registries.nameandregistry.name(e.g.prefapp.azureacr.io. See Build Images -> Configuration)DOCKER_REGISTRY_SNAPSHOTS: base URL of the Docker registry for snapshots. Follows the same format asextra_registries.nameandregistry.name(e.g.prefapp.azureacr.io. See Build Images -> Configuration)
About the version field#
Specifies which image to dispatch. Can have any of the following values:
$latest_release: the latest available release$latest_prerelease: the latest available prerelease$branch_<branch_name>: the latest available image associated to<branch_name>- Any commit SHA (both short and long) or tag: the latest available image associated to the input
Feature arguments#
build_snapshots_branch: which branch triggers an automatic snapshot build when pushed to. Defaults to the default branch of the repository, specified underproviders.github.branchStrategy.defaultBranchinside the claim (usuallymainormaster)auth_strategy: which authentication strategy to use when logging into the docker registries. Defaults toazure_oidcbuild_snapshots_filter: filter to apply when automatically building snapshot images. Defaults to an empty string (no filter)build_pre_releases_filter: filter to apply when automatically building pre-release images. Defaults to an empty string (no filter)build_releases_filter: filter to apply when automatically building release images. Defaults to an empty string (no filter)default_snapshots_flavors_filter: default filter shown in the UI when manually executing the build snapshots workflow. Defaults to*default_pre_releases_flavors_filter: default filter shown in the UI when manually executing the build pre-releases workflow. Defaults to*default_releases_flavors_filter: default filter shown in the UI when manually executing the build releases workflow. Defaults to*firestartr_config_repo: name of the repository that houses all the config files used by themake_dispatchesworkflow. Defaults to${{ github.repository_owner }}/.firestartrmake_dispatches_config_file_path: path to themake_dispatchesconfig file to be used by themake_dispatchesworkflow, relative to the root of the repository. Defaults to.github/make_dispatches.yamlapps_folder_path: path to theappsfolder to be used by themake_dispatchesworkflow. This is a path local to the runner, used after all the configuration repositories have been downloaded. Defaults to.firestartr/appsplatform_folder_path: path to theplatformsfolder to be used by themake_dispatchesworkflow. This is a path local to the runner, used after all the configuration repositories have been downloaded. Defaults to.firestartr/platformsregistries_folder_path: path to theregistriesfolder to be used by themake_dispatchesworkflow. This is a path local to the runner, used after all the configuration repositories have been downloaded. Defaults to.firestartr/registries
NOTE: make_dispatches downloads the firestartr_config_repo repository to access the configuration files via the apps_folder_path, platform_folder_path and registries_folder_path feature arguments. However, firestartr_config_repo is always downloaded under the .firestartr folder, regardless of what the actual name of the repository is, so the paths specified in the *_folder_path arguments should all start with .firestartr/ (unless the folders are located in another repo)