mirror of
https://github.com/germondai/trawl.git
synced 2026-08-17 12:11:23 +02:00
137 lines
4.2 KiB
YAML
137 lines
4.2 KiB
YAML
name: Publish Nightly
|
|
|
|
# Builds the disposable `:nightly` and `:nightly-<sha>` tags of
|
|
# `ghcr.io/.../trawl` from `apps/api/Dockerfile` on every push to `main`.
|
|
#
|
|
# Lives separately from publish.yml (release builds on `v*` tags) and
|
|
# publish-baseline.yml (baseline runtime builds on `v*`/`*-baseline` tags)
|
|
# so:
|
|
# - `v*` tag pushes never trigger a nightly rebuild (release is exclusive)
|
|
# - main pushes never trigger a release/baseline rebuild
|
|
# - each workflow has its own GHA cache scope (no cross-pollution)
|
|
#
|
|
# Tag contract:
|
|
# - push to `main` -> :nightly-<sha> + :nightly
|
|
# - `:latest` is intentionally NOT touched here — that's owned by
|
|
# publish.yml and only moves on `v*` release pushes.
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
env:
|
|
IMAGE: ghcr.io/${{ github.repository_owner }}/trawl
|
|
|
|
jobs:
|
|
build:
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- platform: linux/amd64
|
|
runner: ubuntu-latest
|
|
- platform: linux/arm64
|
|
runner: ubuntu-24.04-arm
|
|
|
|
runs-on: ${{ matrix.runner }}
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- uses: docker/login-action@v4
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- uses: docker/setup-buildx-action@v4
|
|
|
|
- uses: docker/metadata-action@v6
|
|
id: meta
|
|
with:
|
|
images: ${{ env.IMAGE }}
|
|
|
|
- name: Sanitize platform name
|
|
run: |
|
|
platform=${{ matrix.platform }}
|
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
|
|
|
- uses: docker/build-push-action@v7
|
|
id: build
|
|
with:
|
|
context: .
|
|
file: apps/api/Dockerfile
|
|
platforms: ${{ matrix.platform }}
|
|
push: true
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true
|
|
cache-from: type=gha,scope=trawl-nightly-${{ matrix.platform }}
|
|
cache-to: type=gha,scope=trawl-nightly-${{ matrix.platform }},mode=max
|
|
secrets: |
|
|
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Export digest
|
|
run: |
|
|
mkdir -p /tmp/digests
|
|
digest="${{ steps.build.outputs.digest }}"
|
|
touch "/tmp/digests/${digest#sha256:}"
|
|
|
|
- uses: actions/upload-artifact@v7
|
|
with:
|
|
name: digests-nightly-${{ env.PLATFORM_PAIR }}
|
|
path: /tmp/digests/*
|
|
if-no-files-found: error
|
|
retention-days: 1
|
|
|
|
merge:
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- uses: actions/download-artifact@v8
|
|
with:
|
|
path: /tmp/digests
|
|
pattern: digests-nightly-*
|
|
merge-multiple: true
|
|
|
|
- uses: docker/login-action@v4
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- uses: docker/setup-buildx-action@v4
|
|
|
|
- uses: docker/metadata-action@v6
|
|
id: meta
|
|
with:
|
|
images: ${{ env.IMAGE }}
|
|
tags: |
|
|
# main branch push → :nightly (disposable test build).
|
|
type=raw,value=nightly
|
|
# main branch push → :nightly-<sha> for traceability.
|
|
type=sha,prefix=nightly-
|
|
|
|
- name: Create and push multi-arch manifest
|
|
working-directory: /tmp/digests
|
|
run: |
|
|
docker buildx imagetools create \
|
|
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
|
|
$(printf '${{ env.IMAGE }}@sha256:%s ' *)
|
|
|
|
- name: Inspect manifest
|
|
run: |
|
|
# Pull the first tag actually pushed by docker/metadata-action in the
|
|
# previous step. DOCKER_METADATA_OUTPUT_JSON.tags[] is already
|
|
# fully-qualified ("ghcr.io/germondai/trawl:nightly-…") so no $IMAGE
|
|
# prefix needed — the legacy logic re-derived from github.ref /
|
|
# github.sha which disagreed with what got pushed (type=sha writes
|
|
# short 7-char SHA but github.sha is the full 40-char hash).
|
|
tag=$(jq -r '.tags[0]' <<< "$DOCKER_METADATA_OUTPUT_JSON")
|
|
docker buildx imagetools inspect "$tag"
|