Skip to content

Merge branch 'pipeline' #161

Merge branch 'pipeline'

Merge branch 'pipeline' #161

name: "Container Build"
on:
workflow_dispatch: # needed for manually running this workflow
schedule:
- cron: "15 3 * * *" # sadly there is no TZ support here
push:
branches:
- "main"
permissions:
contents: read
packages: write
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 60
container:
image: moby/buildkit:latest
options: --privileged
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Build container
run: |
# ghcr requires lowercase repository names; normalize `MagicMirrorOrg/MagicMirror-3rd-Party-Modules`
REPO="$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]')"
case "${{ github.event_name }}" in
workflow_dispatch)
# manual runs should publish a refreshed image tag
PARAMS="--output type=image,\"name=ghcr.io/${REPO}:${{ github.ref_name }}\",push=true"
;;
schedule)
# nightly cron refresh publishes the image used by the website
PARAMS="--output type=image,\"name=ghcr.io/${REPO}:${{ github.ref_name }}\",push=true"
;;
push)
# changes on main publish the branch tag
PARAMS="--output type=image,\"name=ghcr.io/${REPO}:${{ github.ref_name }}\",push=true"
;;
*)
# fallback: build without pushing, but still run full build pipeline
PARAMS="--output type=image,push=false"
;;
esac
# registry credentials
export DOCKER_CONFIG="$(pwd)/container"
echo "{\"auths\":{\"ghcr.io\":{\"auth\":\"$(echo -n ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} | base64 -w 0)\"}}}" > $DOCKER_CONFIG/config.json
# build
buildctl-daemonless.sh build \
--progress plain \
--frontend=dockerfile.v0 \
--local context=. \
--local dockerfile=container \
$PARAMS