From b59388065f344650d3594936d67cd718782efcd9 Mon Sep 17 00:00:00 2001 From: Mateusz Pstrucha Date: Thu, 1 Oct 2026 20:10:09 +0200 Subject: [PATCH] Push the release image with the shared ygg push-image action Replaces the hand-written login/build/push/logout steps with ygg/actions/push-image@v2. Tags stay the same (X.Y.Z and latest, same image name); it adds OCI source/revision/created/version labels and logs in through a temporary DOCKER_CONFIG, so the registry token never touches the shared runner's ~/.docker. The job now exposes the version and digest as outputs, ready for a deploy job. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/release.yml | 50 ++++++++++++------------------------ docs/release-process.md | 4 +-- 2 files changed, 19 insertions(+), 35 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index fb7c17c..29d8fb7 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -7,42 +7,26 @@ on: jobs: image: runs-on: rocky-10 + outputs: + version: ${{ steps.image.outputs.version }} + digest: ${{ steps.image.outputs.digest }} steps: - name: Check out source uses: actions/checkout@v4 - - name: Derive registry and version - id: meta - run: | - # gitea.server_url is the web root, e.g. https://git.app.ygg — the - # container registry lives on that same host, so there's no - # hostname to hardcode or keep in sync. - REGISTRY="$(echo '${{ gitea.server_url }}' | sed -E 's#^https?://##')" - VERSION="${GITHUB_REF_NAME#v}" - echo "registry=$REGISTRY" >> "$GITHUB_OUTPUT" - echo "image=$REGISTRY/${{ gitea.repository }}" >> "$GITHUB_OUTPUT" - echo "version=$VERSION" >> "$GITHUB_OUTPUT" - - - name: Log in to container registry - run: | - echo '${{ secrets.REGISTRY_TOKEN }}' \ - | docker login '${{ steps.meta.outputs.registry }}' \ - -u '${{ gitea.actor }}' --password-stdin - + # The shared ygg action builds ./Dockerfile as + # git.app.ygg/mtps/tern-server, tagged with the version (v stripped) + # and latest, with OCI source/revision/created/version labels. It logs + # in through a temporary DOCKER_CONFIG, so the token never lands in the + # runner's ~/.docker, and builds with --progress=plain. - name: Build and push image - env: - DOCKER_BUILDKIT: '1' - run: | - IMAGE='${{ steps.meta.outputs.image }}' - VERSION='${{ steps.meta.outputs.version }}' - # --progress=plain: without it BuildKit renders an animated TTY - # progress display, repainting every step on each frame. In a log - # file that became ~15k lines of cursor-movement escapes for a - # build that only has a few hundred lines of real output. - docker build --progress=plain -t "$IMAGE:$VERSION" -t "$IMAGE:latest" . - docker push "$IMAGE:$VERSION" - docker push "$IMAGE:latest" + id: image + uses: https://git.app.ygg/ygg/actions/push-image@v2 + with: + registry-token: ${{ secrets.REGISTRY_TOKEN }} - - name: Log out - if: always() - run: docker logout '${{ steps.meta.outputs.registry }}' || true + - name: Show image + env: + TAGS: ${{ steps.image.outputs.tags }} + DIGEST: ${{ steps.image.outputs.digest }} + run: printf 'tags: %s\ndigest: %s\n' "$TAGS" "$DIGEST" diff --git a/docs/release-process.md b/docs/release-process.md index d8cddd0..e051507 100644 --- a/docs/release-process.md +++ b/docs/release-process.md @@ -114,8 +114,8 @@ All three workflows target `runs-on: rocky-10` and follow the conventions alread What still needs doing, in order of how likely it is to bite: -1. **`REGISTRY_TOKEN` secret on `tern-server`** — a token with `write:package` scope, for pushing the image. Unlike the release jobs, this one can't use the automatic `GITHUB_TOKEN`, whose scope doesn't reliably cover the package registry. (Worth trying `GITHUB_TOKEN` first on your instance; if it works, drop the extra secret.) -2. **The container registry is enabled**, and `gitea.server_url` matches the registry host. The workflow derives the registry from that rather than hardcoding — verify on the first run that the pushed image lands where you expect. +1. **`REGISTRY_TOKEN` secret on `tern-server`** — a token with `write:package` scope, for pushing the image. The automatic `GITHUB_TOKEN` can't push packages on this instance. The secret is passed to the shared [`ygg/actions/push-image`](https://git.app.ygg/ygg/actions/src/branch/main/push-image) action as an input, because actions can't read secrets themselves. +2. **The container registry is enabled**, and `gitea.server_url` matches the registry host. `push-image` derives the registry from it rather than hardcoding one, and pushes `git.app.ygg/mtps/tern-server`. 3. **Android signing secrets** — see §3 above: `ANDROID_KEYSTORE_B64`, `ANDROID_KEYSTORE_PASSWORD`, `ANDROID_KEY_ALIAS`, `ANDROID_KEY_PASSWORD`. 4. **`docker build` available to the job** — already proven on this runner.