Build base image workflow (music-assistant/server)
The Build base image workflow from music-assistant/server, explained and optimized by Latchkey.
CI health: B - good
Point runs-on at Latchkey and get job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Build base image workflow from the music-assistant/server repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Build base image
on:
workflow_dispatch:
inputs:
version:
description: "Version number"
required: true
type: string
jobs:
build-base-image:
name: Builds and pushes the Music Assistant base container to ghcr.io
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- uses: actions/checkout@v7
- name: Read Python version
id: python
run: echo "version=$(cat .python-version)" >> $GITHUB_OUTPUT
- name: Download Widevine CDM client files from private repository
shell: bash
env:
TOKEN: ${{ secrets.PRIVILEGED_GITHUB_TOKEN }}
run: |
mkdir -p widevine_cdm && cd widevine_cdm
curl -OJ -H "Authorization: token ${TOKEN}" https://raw.githubusercontent.com/music-assistant/appvars/main/widevine_cdm_client/private_key.pem
curl -OJ -H "Authorization: token ${TOKEN}" https://raw.githubusercontent.com/music-assistant/appvars/main/widevine_cdm_client/client_id.bin
- name: Log in to the GitHub container registry
uses: docker/login-action@v4.4.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4.2.0
- name: Build and Push image
uses: docker/build-push-action@v7.3.0
with:
context: .
platforms: linux/amd64,linux/arm64
file: Dockerfile.base
build-args: |
PYTHON_VERSION=${{ steps.python.outputs.version }}
tags: |-
ghcr.io/${{ github.repository_owner }}/base:${{ inputs.version }},
ghcr.io/${{ github.repository_owner }}/base:latest
push: true
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Build base image on: workflow_dispatch: inputs: version: description: "Version number" required: true type: string jobs: build-base-image: timeout-minutes: 30 name: Builds and pushes the Music Assistant base container to ghcr.io runs-on: latchkey-small permissions: packages: write steps: - uses: actions/checkout@v7 - name: Read Python version id: python run: echo "version=$(cat .python-version)" >> $GITHUB_OUTPUT - name: Download Widevine CDM client files from private repository shell: bash env: TOKEN: ${{ secrets.PRIVILEGED_GITHUB_TOKEN }} run: | mkdir -p widevine_cdm && cd widevine_cdm curl -OJ -H "Authorization: token ${TOKEN}" https://raw.githubusercontent.com/music-assistant/appvars/main/widevine_cdm_client/private_key.pem curl -OJ -H "Authorization: token ${TOKEN}" https://raw.githubusercontent.com/music-assistant/appvars/main/widevine_cdm_client/client_id.bin - name: Log in to the GitHub container registry uses: docker/login-action@v4.4.0 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4.2.0 - name: Build and Push image uses: docker/build-push-action@v7.3.0 with: context: . platforms: linux/amd64,linux/arm64 file: Dockerfile.base build-args: | PYTHON_VERSION=${{ steps.python.outputs.version }} tags: |- ghcr.io/${{ github.repository_owner }}/base:${{ inputs.version }}, ghcr.io/${{ github.repository_owner }}/base:latest push: true
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Add a job timeout so a hung step cannot burn hours of runner time.
3 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- Container pulls and builds
- Network fetches
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.