Diffinery

homeflare/celldpublic

celld/.github/workflows/homeflare-image.yml
71 lines · 2.4 KBRaw History
1name: Homeflare image
2
3# Builds this fork's celld image and pushes it to GHCR, for Homeflare's
4# runtime image to build on:
5#
6# ghcr.io/<owner>/celld:<first 12 of the commit> what Homeflare pins
7# ghcr.io/<owner>/celld:main the latest main
8#
9# The Dockerfile is upstream's: the image builds only if cargo test and
10# cargo clippy -D warnings pass. Layers are cached in the registry
11# (:buildcache-amd64), so a patch only rebuilds what it touches.
12#
13# Upstream's release.yml (native binaries, ghcr.io/denoland/celld) is left as
14# it is; it only runs on a `candidate` push or a published release.
15on:
16 push:
17 branches: [main]
18 paths-ignore:
19 - "**.md"
20 - "docs/**"
21 - "homeflare/smoke/**"
22 workflow_dispatch:
23
24permissions:
25 contents: read
26
27concurrency:
28 group: homeflare-image-${{ github.ref }}
29 cancel-in-progress: true
30
31jobs:
32 image:
33 name: Build and push
34 # GHCR takes GitHub's token only: a mirror (git.1j.nz) has its own forge's.
35 if: github.server_url == 'https://github.com'
36 runs-on: ubuntu-22.04
37 timeout-minutes: 120
38 permissions:
39 contents: read
40 packages: write
41 steps:
42 - uses: actions/checkout@v6
43
44 - uses: docker/setup-buildx-action@v3
45
46 - name: Log in to GHCR
47 env:
48 GHCR_TOKEN: ${{ github.token }}
49 run: |
50 printf '%s' "$GHCR_TOKEN" |
51 docker login ghcr.io --username "$GITHUB_ACTOR" --password-stdin
52
53 - name: Build, test and push
54 run: |
55 set -euo pipefail
56 image="ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/celld"
57 version=$(sed -n 's/^version = "\(.*\)"$/\1/p' crates/celld/Cargo.toml | head -1)
58 docker buildx build \
59 --platform linux/amd64 \
60 --build-arg "CELLD_COMMIT=$GITHUB_SHA" \
61 --build-arg "CELLD_VERSION=$version" \
62 --label "org.opencontainers.image.source=https://github.com/$GITHUB_REPOSITORY" \
63 --cache-from "type=registry,ref=$image:buildcache-amd64" \
64 --cache-to "type=registry,ref=$image:buildcache-amd64,mode=max" \
65 --tag "$image:${GITHUB_SHA::12}" \
66 --tag "$image:main" \
67 --push \
68 .
69 echo "### Pushed \`$image:${GITHUB_SHA::12}\`" >> "$GITHUB_STEP_SUMMARY"
70 echo "" >> "$GITHUB_STEP_SUMMARY"
71 echo "Homeflare: \`HOMEFLARE_CELLD_IMAGE=$image:${GITHUB_SHA::12}\`" >> "$GITHUB_STEP_SUMMARY"