From 54f42848a37430669a92675531d9f5dd10c7b313 Mon Sep 17 00:00:00 2001 From: benoit74 Date: Mon, 30 Nov 2026 17:06:14 +0000 Subject: [PATCH] Use openzim/overview's reusable docker-publish workflow [openzim/docker-publish-action](https://github.com/openzim/docker-publish-action) is deprecated (openzim/docker-publish-action#10). Image building and publishing now goes through the reusable workflow in [openzim/overview](https://github.com/openzim/overview/blob/main/.github/workflows/docker-publish.yaml), which builds each architecture on its own native runner and merges the digests into a single multi-arch manifest. What the rewrite does, per [the migration guide](https://github.com/openzim/overview/wiki/Publishing-Docker-images#migrating-from-docker-publish-action): - the publishing step becomes a job calling the reusable workflow (a `uses:` job cannot hold `steps`, so anything else the job did stays in its own job, wired with `needs:` to keep the original ordering) - `restrict-to` becomes an `if: github.repository == ...` guard on the job - `credentials` becomes the `ghcr_username` / `ghcr_token` secrets - `on-master` is renamed `on-main` (same meaning: the repository's default branch) - `registries`, `repo_description` and `repo_overview` are dropped: they only ever mattered for docker.io, which this repository does not publish to Image names, tags, platforms, context, Dockerfile and build args are unchanged. --- .github/workflows/Publish.yaml | 25 +++++++++-------- .github/workflows/PublishDockerDevImage.yaml | 27 +++++++------------ docs/Dockerfile-and-Publish-workflow.md | 28 +++++++++++++++++--- 3 files changed, 46 insertions(+), 34 deletions(-) diff --git a/.github/workflows/Publish.yaml b/.github/workflows/Publish.yaml index 7810ea3..35b3c71 100644 --- a/.github/workflows/Publish.yaml +++ b/.github/workflows/Publish.yaml @@ -37,16 +37,15 @@ jobs: # password: ${{ secrets.PYPI_TEST_API_TOKEN }} # repository_url: https://test.pypi.org/legacy/ - - name: Build and push Docker image - uses: openzim/docker-publish-action@v10 - with: - image-name: openzim/great-project - tag-pattern: /^v([0-9.]+)$/ - latest-on-tag: true - restrict-to: openzim/_python-bootstrap - registries: ghcr.io - credentials: - GHCRIO_USERNAME=${{ secrets.GHCR_USERNAME }} - GHCRIO_TOKEN=${{ secrets.GHCR_TOKEN }} - repo_description: auto - repo_overview: auto + docker-publish: + name: Build and push Docker image + if: github.repository == 'openzim/_python-bootstrap' + needs: publish + uses: openzim/overview/.github/workflows/docker-publish.yaml@v1 + with: + image-name: openzim/great-project + tag-pattern: /^v([0-9.]+)$/ + latest-on-tag: true + secrets: + ghcr_username: ${{ secrets.GHCR_USERNAME }} + ghcr_token: ${{ secrets.GHCR_TOKEN }} diff --git a/.github/workflows/PublishDockerDevImage.yaml b/.github/workflows/PublishDockerDevImage.yaml index 3fd398a..ae5f909 100644 --- a/.github/workflows/PublishDockerDevImage.yaml +++ b/.github/workflows/PublishDockerDevImage.yaml @@ -7,21 +7,12 @@ on: jobs: publish: - runs-on: ubuntu-24.04 - - steps: - - uses: actions/checkout@v4 - - - name: Build and push Docker image - uses: openzim/docker-publish-action@v10 - with: - image-name: openzim/great-project - manual-tag: dev - latest-on-tag: false - restrict-to: openzim/_python-bootstrap - registries: ghcr.io - credentials: - GHCRIO_USERNAME=${{ secrets.GHCR_USERNAME }} - GHCRIO_TOKEN=${{ secrets.GHCR_TOKEN }} - repo_description: auto - repo_overview: auto + if: github.repository == 'openzim/_python-bootstrap' + uses: openzim/overview/.github/workflows/docker-publish.yaml@v1 + with: + image-name: openzim/great-project + latest-on-tag: false + manual-tag: dev + secrets: + ghcr_username: ${{ secrets.GHCR_USERNAME }} + ghcr_token: ${{ secrets.GHCR_TOKEN }} diff --git a/docs/Dockerfile-and-Publish-workflow.md b/docs/Dockerfile-and-Publish-workflow.md index 1516eaa..33e9f85 100644 --- a/docs/Dockerfile-and-Publish-workflow.md +++ b/docs/Dockerfile-and-Publish-workflow.md @@ -51,13 +51,35 @@ on: types: [published] ``` -## Publish action - -Except if not appropriate, we recommend to use our specific Github action : [openzim/docker-publish-action](https://github.com/openzim/docker-publish-action) which handles building the image and publishing it. +## Publish workflow + +Except if not appropriate, we recommend to call our reusable workflow +[openzim/overview/.github/workflows/docker-publish.yaml](https://github.com/openzim/overview/blob/main/.github/workflows/docker-publish.yaml), +which handles building the image (each architecture on its own native runner) and publishing it. Its inputs +are documented in [Publishing Docker images](https://github.com/openzim/overview/wiki/Publishing-Docker-images). + +```yaml +jobs: + docker-publish: + if: github.repository == 'openzim/great-project' + uses: openzim/overview/.github/workflows/docker-publish.yaml@v1 + with: + image-name: openzim/great-project + tag-pattern: /^v([0-9.]+)$/ + latest-on-tag: true + secrets: + ghcr_username: ${{ secrets.GHCR_USERNAME }} + ghcr_token: ${{ secrets.GHCR_TOKEN }} +``` Some quirks not to forget: - Image name convention is to use dashes not underscores +- a job calling a reusable workflow cannot have `steps`, so anything else the release workflow does (building + and uploading the Python package, for instance) belongs in its own job, which the publishing job waits on + with `needs:` +- [openzim/docker-publish-action](https://github.com/openzim/docker-publish-action), which we used before, is + deprecated: do not use it in new projects ## Registry