Files
dotcom-arcade/.gitea/workflows/images.yml
T

112 lines
4.1 KiB
YAML

# Builds the app, session manager and streamer images and pushes them to this
# Gitea instance's container registry, under the repository's owner.
#
# Needs a repository secret REGISTRY_TOKEN: an access token with package write
# access, belonging to the repository's owner. If the runner reaches Gitea at a
# different address than the registry's public one, set a repository variable
# REGISTRY_HOST to the registry's host name.
name: Images
on:
push:
branches: [main]
workflow_dispatch:
# Jobs that run docker builds use dejima-privileged; anything else should use
# dejima-confined.
jobs:
build:
name: ${{ matrix.name }}
runs-on: dejima-privileged
strategy:
fail-fast: false
matrix:
include:
- name: app
image: dotcom-arcade
context: .
- name: session-manager
image: dotcom-arcade-session-manager
context: streaming/session-manager
- name: streamer
image: dotcom-arcade-streamer
context: streaming/streamer
steps:
- uses: actions/checkout@v4
# The runner mounts the host's Docker socket, but its job image ships no
# Docker client, and the login and build actions shell out to `docker`.
# Only Docker's repository is refreshed, so the job needs no other mirrors.
- name: Install the Docker CLI
run: |
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" > /etc/apt/sources.list.d/docker.list
apt-get update -o Dir::Etc::sourcelist=sources.list.d/docker.list -o Dir::Etc::sourceparts=- -o APT::Get::List-Cleanup=0
apt-get install -y --no-install-recommends docker-ce-cli
# The registry is this Gitea instance, unless REGISTRY_HOST says otherwise
- name: Locate the registry
id: registry
shell: bash
env:
REGISTRY_HOST: ${{ vars.REGISTRY_HOST }}
run: |
host=${GITHUB_SERVER_URL#*://}
host=${REGISTRY_HOST:-${host%/}}
echo "host=$host" >> "$GITHUB_OUTPUT"
echo "owner=${GITHUB_REPOSITORY_OWNER,,}" >> "$GITHUB_OUTPUT"
# Shown in Settings, since images carry no version number
- name: Name the version
id: version
shell: bash
run: echo "sha=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ${{ steps.registry.outputs.host }}
username: ${{ github.repository_owner }}
password: ${{ secrets.REGISTRY_TOKEN }}
- id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.registry.outputs.host }}/${{ steps.registry.outputs.owner }}/${{ matrix.image }}
tags: type=raw,value=latest
# GHCR sometimes answers the streamer's base image pull with 429 Too Many
# Requests; it clears within minutes, so retry once.
- id: build
uses: docker/build-push-action@v6
continue-on-error: true
with:
context: ${{ matrix.context }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
build-args: |
VERSION=${{ steps.version.outputs.sha }}
provenance: false
- name: Wait before retrying
if: steps.build.outcome == 'failure'
run: sleep 120
- name: Retry the build
if: steps.build.outcome == 'failure'
uses: docker/build-push-action@v6
with:
context: ${{ matrix.context }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
build-args: |
VERSION=${{ steps.version.outputs.sha }}
provenance: false