From 2f98d837ffd7ec57fba80e12d6e36168b60a17e4 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Sat, 4 May 2024 21:55:52 +0200 Subject: [PATCH] ci: Push docker hub description automatically on main branch --- .github/workflows/ci.yaml | 29 +++++++----- nix/tools/release/default.nix | 47 +------------------ nix/tools/release/docker-hub-description.md | 1 - .../release/docker-hub-full-description.md | 2 + 4 files changed, 20 insertions(+), 59 deletions(-) delete mode 100644 nix/tools/release/docker-hub-description.md diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b2f842325..9fc6a0d4c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -283,18 +283,23 @@ jobs: else echo "Skipping push to 'latest' tag for pre-release..." fi -# TODO: Enable dockerhub description update again, once a solution for the permission problem is found: -# https://github.com/docker/hub-feedback/issues/1927 -# - name: Update descriptions on Docker Hub -# env: -# DOCKER_PASS: ${{ secrets.DOCKER_PASS }} -# run: | -# if [[ -z "$ISPRERELEASE" ]]; then -# echo "Updating description on Docker Hub..." -# postgrest-release-dockerhub-description -# else -# echo "Skipping updating description for pre-release..." -# fi + + + docker-description: + name: Release / Docker Hub Description + runs-on: ubuntu-22.04 + if: | + vars.DOCKER_REPO && vars.DOCKER_USER && + github.ref == 'refs/tags/devel' + steps: + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - uses: peter-evans/dockerhub-description@e98e4d1628a5f3be2be7c231e50981aee98723ae # v4.0.0 + with: + username: ${{ vars.DOCKER_USER }} + password: ${{ secrets.DOCKER_PASS }} + repository: ${{ vars.DOCKER_REPO }}/postgrest + short-description: ${{ github.event.repository.description }} + readme-filepath: ./nix/tools/release/docker-hub-full-description.md docker-arm: diff --git a/nix/tools/release/default.nix b/nix/tools/release/default.nix index d3b93705d..104bfb5f2 100644 --- a/nix/tools/release/default.nix +++ b/nix/tools/release/default.nix @@ -1,52 +1,7 @@ { buildToolbox , checkedShellScript -, curl -, jq }: let - dockerHubDescription = - let - description = - ./docker-hub-description.md; - - fullDescription = - ./docker-hub-full-description.md; - in - checkedShellScript - { - name = "postgrest-release-dockerhub-description"; - docs = "Update the repository description on Docker Hub."; - args = [ - "ARG_USE_ENV([DOCKER_USER], [], [DockerHub user name])" - "ARG_USE_ENV([DOCKER_PASS], [], [DockerHub password])" - "ARG_USE_ENV([DOCKER_REPO], [], [DockerHub repository])" - ]; - } - '' - # ARG_USE_ENV only adds defaults or docs for environment variables - # We manually implement a required check here - # See also: https://github.com/matejak/argbash/issues/80 - : "''${DOCKER_USER:?DOCKER_USER is required}" - : "''${DOCKER_PASS:?DOCKER_PASS is required}" - : "''${DOCKER_REPO:?DOCKER_REPO is required}" - - echo "Logging in to Docker Hub to get an auth token..." - token="$( - ${curl}/bin/curl --fail -s \ - --data-urlencode "username=$DOCKER_USER" \ - --data-urlencode "password=$DOCKER_PASS" \ - "https://hub.docker.com/v2/users/login/" \ - | ${jq}/bin/jq -r .token - )" - - repo_url="https://hub.docker.com/v2/repositories/$DOCKER_REPO/postgrest/" - echo "Patching both descriptions at $repo_url ..." - ${curl}/bin/curl --fail -X PATCH "$repo_url" \ - -H "Authorization: JWT $token" \ - --data-urlencode description@${description} \ - --data-urlencode full_description@${fullDescription} - ''; - release = checkedShellScript { @@ -133,5 +88,5 @@ in buildToolbox { name = "postgrest-release"; - tools = { inherit dockerHubDescription release; }; + tools = { inherit release; }; } diff --git a/nix/tools/release/docker-hub-description.md b/nix/tools/release/docker-hub-description.md deleted file mode 100644 index fc44c8542..000000000 --- a/nix/tools/release/docker-hub-description.md +++ /dev/null @@ -1 +0,0 @@ -REST API for any Postgres database diff --git a/nix/tools/release/docker-hub-full-description.md b/nix/tools/release/docker-hub-full-description.md index 625e2723d..d38ef33bf 100644 --- a/nix/tools/release/docker-hub-full-description.md +++ b/nix/tools/release/docker-hub-full-description.md @@ -68,3 +68,5 @@ The image is built from scratch using no commands are listed in the image history. See the [PostgREST respository](https://github.com/PostgREST/postgrest/tree/main/nix/tools/docker) for details on the build process and how to inspect the image. + +This does not apply to the arm64 variant, which is based on Ubuntu.