| 1 | name: 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. |
| 15 | on: |
| 16 | push: |
| 17 | branches: [main] |
| 18 | paths-ignore: |
| 19 | - "**.md" |
| 20 | - "docs/**" |
| 21 | - "homeflare/smoke/**" |
| 22 | workflow_dispatch: |
| 23 | |
| 24 | permissions: |
| 25 | contents: read |
| 26 | |
| 27 | concurrency: |
| 28 | group: homeflare-image-${{ github.ref }} |
| 29 | cancel-in-progress: true |
| 30 | |
| 31 | jobs: |
| 32 | image: |
| 33 | name: Build and push |
| 34 | runs-on: ubuntu-22.04 |
| 35 | timeout-minutes: 120 |
| 36 | permissions: |
| 37 | contents: read |
| 38 | packages: write |
| 39 | steps: |
| 40 | - uses: actions/checkout@v6 |
| 41 | |
| 42 | - uses: docker/setup-buildx-action@v3 |
| 43 | |
| 44 | - name: Log in to GHCR |
| 45 | env: |
| 46 | GHCR_TOKEN: ${{ github.token }} |
| 47 | run: | |
| 48 | printf '%s' "$GHCR_TOKEN" | |
| 49 | docker login ghcr.io --username "$GITHUB_ACTOR" --password-stdin |
| 50 | |
| 51 | - name: Build, test and push |
| 52 | run: | |
| 53 | set -euo pipefail |
| 54 | image="ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/celld" |
| 55 | version=$(sed -n 's/^version = "\(.*\)"$/\1/p' crates/celld/Cargo.toml | head -1) |
| 56 | docker buildx build \ |
| 57 | --platform linux/amd64 \ |
| 58 | --build-arg "CELLD_COMMIT=$GITHUB_SHA" \ |
| 59 | --build-arg "CELLD_VERSION=$version" \ |
| 60 | --label "org.opencontainers.image.source=https://github.com/$GITHUB_REPOSITORY" \ |
| 61 | --cache-from "type=registry,ref=$image:buildcache-amd64" \ |
| 62 | --cache-to "type=registry,ref=$image:buildcache-amd64,mode=max" \ |
| 63 | --tag "$image:${GITHUB_SHA::12}" \ |
| 64 | --tag "$image:main" \ |
| 65 | --push \ |
| 66 | . |
| 67 | echo "### Pushed \`$image:${GITHUB_SHA::12}\`" >> "$GITHUB_STEP_SUMMARY" |
| 68 | echo "" >> "$GITHUB_STEP_SUMMARY" |
| 69 | echo "Homeflare: \`HOMEFLARE_CELLD_IMAGE=$image:${GITHUB_SHA::12}\`" >> "$GITHUB_STEP_SUMMARY" |