Files
Draupnir/.github/workflows/ghcr-all-dev-branches.yml
Catalan Lover 9902993b6c
Some checks failed
GHCR - Development Branches / ghcr-publish (push) Failing after 39s
Docker Hub - Develop / docker-latest (push) Failing after 40s
Tests / Application Service Integration tests (push) Failing after 13m52s
Tests / Integration tests (push) Failing after 13m54s
Tests / Unit tests (push) Failing after 13m57s
Tests / Build & Lint (push) Failing after 13m59s
Implement Caching for the CI (#1055)
* Update Dockerignore

Updates dockerignore to protect against cache contamination so we can more effectively utilise the full potential of our Cache system.

* Implement Caching strategy support in dockerfile

* Implement Caching for CI to massively speed up warm builds

* Fix Wildcard funkyness breaking docker builds.

* Fix FROM AS style guideline violations

There's a style guideline that says you shouldn't mix the case of FROM and AS in a FROM AS statement. So we fix this violation in this commit.

You can also force it all to lowercase but considering all our other keywords are uppercase why not go uppercase only for consistency.
2026-03-25 16:18:18 +00:00

87 lines
2.7 KiB
YAML

# SPDX-FileCopyrightText: 2026 Catalan Lover <catalanlover@protonmail.com>
#
# SPDX-License-Identifier: CC0-1.0
# This file is derived from the docker-hub-develop.yml workflow, but instead of pushing to Docker Hub, it pushes to GHCR. It also runs on all non excluded branches to allow easier access to development builds.
name: "GHCR - Development Branches"
on:
push:
branches-ignore:
- "dependabot/**"
- "renovate/**"
- "github-actions/**"
concurrency:
group: ghcr-dev-${{ github.ref }}
cancel-in-progress: true
env:
IMAGE_NAME: draupnir
PLATFORMS: linux/amd64,linux/arm64
IMG_SOURCE: https://github.com/${{ github.repository }}
jobs:
ghcr-publish:
runs-on: ubuntu-latest
permissions:
id-token: write
packages: write
contents: read
attestations: write
steps:
- name: Check out
uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
- name: Set lowercase image owner
id: image_owner
run: echo "image_owner=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
# Needed for multi platform builds
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
with:
platforms: ${{ env.PLATFORMS }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Derive image tags
id: meta
uses: docker/metadata-action@v6
with:
images: ghcr.io/${{ steps.image_owner.outputs.image_owner }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=sha,prefix=sha-
- name: Build image
id: push
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
platforms: ${{ env.PLATFORMS }}
push: true
# Shared Buildx cache scope reused by all container image workflows.
# Keep the scope name aligned across workflows to maximize cache hits.
cache-from: type=gha,scope=draupnir-container-build
cache-to: type=gha,scope=draupnir-container-build,mode=max
labels: |
org.opencontainers.image.source=${{ env.IMG_SOURCE }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.version=${{ github.ref_name }}-${{ github.sha }}
org.opencontainers.image.ref.name=${{ github.ref_name }}
org.opencontainers.image.licenses=AFL-3.0
sbom: true
tags: ${{ steps.meta.outputs.tags }}