neiam
/recourse
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
CI: build and push the service image on every push to master (mail-prism's image.yml)
e7d5438 · gmorell · 2026-12-03 01:40
Files changed
added
.forgejo/workflows/image.yml
+73
−0
@@ -0,0 +1,73 @@
| 1 | +# Builds the recourse image (web service + `manage` CLI) and pushes it to | |
| 2 | +# the forge's own OCI registry on every push to master: mail-prism's | |
| 3 | +# workflow, which is dms's. The contract: one image per push to master, | |
| 4 | +# tagged :latest (plus :master and the full commit sha), at | |
| 5 | +# <registry>/<owner>/<repo>, i.e. <CI_REGISTRY>/neiam/recourse. | |
| 6 | +# | |
| 7 | +# No secrets. The per-job token is accepted by the registry's /v2/token | |
| 8 | +# endpoint and authorized to push this repository's own image path, the | |
| 9 | +# same deal the F-Droid and apt registries give. | |
| 10 | +# | |
| 11 | +# The Android app is not in this image (.dockerignore drops android/); | |
| 12 | +# android.yml builds it. | |
| 13 | +name: image | |
| 14 | +on: | |
| 15 | + push: | |
| 16 | + branches: [master] | |
| 17 | + | |
| 18 | +jobs: | |
| 19 | + image: | |
| 20 | + runs-on: self-hosted | |
| 21 | + steps: | |
| 22 | + - uses: actions/checkout@v4 | |
| 23 | + | |
| 24 | + - uses: docker/setup-buildx-action@v3 | |
| 25 | + | |
| 26 | + # An unset CI_REGISTRY resolves to the empty string, and | |
| 27 | + # login-action then silently defaults to docker.io while | |
| 28 | + # metadata-action builds a nonsense "/owner/repo" reference. Say | |
| 29 | + # what is missing instead. | |
| 30 | + - name: Check the registry variable is set | |
| 31 | + env: | |
| 32 | + CI_REGISTRY: ${{ vars.CI_REGISTRY }} | |
| 33 | + run: | | |
| 34 | + set -euo pipefail | |
| 35 | + if [ -z "${CI_REGISTRY:-}" ]; then | |
| 36 | + echo "CI_REGISTRY is not set for this repository." >&2 | |
| 37 | + echo "Set it as an organisation-level Actions variable (the" >&2 | |
| 38 | + echo "registry hostname), the same one gitgud builds against." >&2 | |
| 39 | + exit 1 | |
| 40 | + fi | |
| 41 | + echo "pushing to $CI_REGISTRY" | |
| 42 | + | |
| 43 | + # The username is ignored by the token endpoint but login-action | |
| 44 | + # requires it to be non-empty. | |
| 45 | + - uses: docker/login-action@v3 | |
| 46 | + with: | |
| 47 | + registry: ${{ vars.CI_REGISTRY }} | |
| 48 | + username: ci | |
| 49 | + password: ${{ github.token }} | |
| 50 | + | |
| 51 | + # Push to the job's OWN repo path (<registry>/<owner>/<repo>); the | |
| 52 | + # per-job token only grants push there. | |
| 53 | + - uses: docker/metadata-action@v5 | |
| 54 | + id: meta | |
| 55 | + with: | |
| 56 | + images: ${{ vars.CI_REGISTRY }}/${{ github.repository }} | |
| 57 | + tags: | | |
| 58 | + type=sha,format=long | |
| 59 | + type=ref,event=branch | |
| 60 | + # Unconditional: `{{is_default_branch}}` evaluates false on this | |
| 61 | + # forge, so :latest was never pushed. The workflow only runs on | |
| 62 | + # master anyway. | |
| 63 | + type=raw,value=latest | |
| 64 | + | |
| 65 | + - uses: docker/build-push-action@v6 | |
| 66 | + with: | |
| 67 | + context: . | |
| 68 | + file: ./Dockerfile | |
| 69 | + push: true | |
| 70 | + tags: ${{ steps.meta.outputs.tags }} | |
| 71 | + labels: ${{ steps.meta.outputs.labels }} | |
| 72 | + cache-from: type=registry,ref=${{ vars.CI_REGISTRY }}/${{ github.repository }}:buildcache | |
| 73 | + cache-to: type=registry,ref=${{ vars.CI_REGISTRY }}/${{ github.repository }}:buildcache,mode=max |
Parents: 72bce3e