From 50c32e351598dbd62cd207bf93535eb46e2883e5 Mon Sep 17 00:00:00 2001 From: Kim Gustyr Date: Thu, 3 Dec 2026 18:05:43 +0100 Subject: [PATCH 1/3] ci: Log in to Quay with OIDC robot federation instead of a stored password --- .../workflows/.reusable-docker-publish.yml | 35 +++++++++++-------- .../mcp-docker-build-publish-deploy.yml | 2 -- .../platform-docker-build-test-publish.yml | 6 ---- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/.github/workflows/.reusable-docker-publish.yml b/.github/workflows/.reusable-docker-publish.yml index dcec970a4c82..7098680b9c4e 100644 --- a/.github/workflows/.reusable-docker-publish.yml +++ b/.github/workflows/.reusable-docker-publish.yml @@ -17,21 +17,13 @@ on: description: URL of the target docker registry required: false default: docker.io - docker-username: - type: string - description: Username for authenticating to a non-Docker Hub registry. Docker Hub uses OIDC. - required: false - default: '' - docker-password-secret-name: - type: string - description: The name of the secret holding the password for a non-Docker Hub registry. Docker Hub uses OIDC. - required: false - default: '' jobs: publish: name: Publish ${{ inputs.source-images }} to ${{ inputs.target-images }} runs-on: depot-ubuntu-latest + # Quay's robot federation matches this environment's OIDC subject; Docker Hub matches the ref, so no environment there. + environment: ${{ inputs.target-registry-url == 'quay.io' && 'quay' || '' }} permissions: contents: read @@ -60,13 +52,26 @@ jobs: with: username: flagsmith - - name: Login to ${{ inputs.target-registry-url }} - if: inputs.target-registry-url != 'docker.io' + - name: Get a short-lived Quay robot token + id: quay + if: inputs.target-registry-url == 'quay.io' + env: + QUAY_ROBOT: ${{ vars.QUAY_PUBLISH_USERNAME }} + run: | + set -euo pipefail + oidc=$(curl -sSf -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL" | jq -r .value) + echo "::add-mask::$oidc" + token=$(curl -sSf -u "$QUAY_ROBOT:$oidc" https://quay.io/oauth2/federation/robot/token | jq -r .token) + echo "::add-mask::$token" + echo "token=$token" >> "$GITHUB_OUTPUT" + + - name: Login to Quay uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0 + if: inputs.target-registry-url == 'quay.io' with: - registry: ${{ inputs.target-registry-url }} - username: ${{ inputs.docker-username }} - password: ${{ secrets[inputs.docker-password-secret-name] }} + registry: quay.io + username: ${{ vars.QUAY_PUBLISH_USERNAME }} + password: ${{ steps.quay.outputs.token }} - name: Docker metadata id: meta diff --git a/.github/workflows/mcp-docker-build-publish-deploy.yml b/.github/workflows/mcp-docker-build-publish-deploy.yml index b75a3380c4e7..4b6f7cb918b8 100644 --- a/.github/workflows/mcp-docker-build-publish-deploy.yml +++ b/.github/workflows/mcp-docker-build-publish-deploy.yml @@ -67,8 +67,6 @@ jobs: if: github.event_name == 'release' with: target-registry-url: quay.io - docker-username: ${{ vars.QUAY_PUBLISH_USERNAME }} - docker-password-secret-name: QUAY_PUBLISH_PASSWORD source-images: ${{ needs.docker-build-mcp.outputs.image }} target-images: quay.io/${{ vars.QUAY_ORGANISATION_NAME }}/flagsmith-mcp secrets: inherit diff --git a/.github/workflows/platform-docker-build-test-publish.yml b/.github/workflows/platform-docker-build-test-publish.yml index 5553c3334902..ae86f30aaa4c 100644 --- a/.github/workflows/platform-docker-build-test-publish.yml +++ b/.github/workflows/platform-docker-build-test-publish.yml @@ -231,8 +231,6 @@ jobs: if: github.event_name == 'release' with: target-registry-url: quay.io - docker-username: ${{ vars.QUAY_PUBLISH_USERNAME }} - docker-password-secret-name: QUAY_PUBLISH_PASSWORD source-images: ${{ needs.docker-build-private-cloud.outputs.image }} target-images: quay.io/${{ vars.QUAY_ORGANISATION_NAME }}/flagsmith-enterprise secrets: inherit @@ -247,8 +245,6 @@ jobs: if: github.event_name == 'release' with: target-registry-url: quay.io - docker-username: ${{ vars.QUAY_PUBLISH_USERNAME }} - docker-password-secret-name: QUAY_PUBLISH_PASSWORD source-images: ${{ needs.docker-build-private-cloud-api.outputs.image }} target-images: quay.io/${{ vars.QUAY_ORGANISATION_NAME }}/flagsmith-enterprise-api secrets: inherit @@ -263,8 +259,6 @@ jobs: if: github.event_name == 'release' with: target-registry-url: quay.io - docker-username: ${{ vars.QUAY_PUBLISH_USERNAME }} - docker-password-secret-name: QUAY_PUBLISH_PASSWORD source-images: ${{ needs.docker-build-frontend.outputs.image }} target-images: quay.io/${{ vars.QUAY_ORGANISATION_NAME }}/flagsmith-frontend secrets: inherit From 9ceb7ae3365b89827e55c99f5d1333cbe433ed6b Mon Sep 17 00:00:00 2001 From: Kim Gustyr Date: Thu, 3 Dec 2026 18:15:41 +0100 Subject: [PATCH 2/3] ci: Request the OIDC token with Quay's federation audience --- .github/workflows/.reusable-docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/.reusable-docker-publish.yml b/.github/workflows/.reusable-docker-publish.yml index 7098680b9c4e..203996fa09ec 100644 --- a/.github/workflows/.reusable-docker-publish.yml +++ b/.github/workflows/.reusable-docker-publish.yml @@ -59,7 +59,7 @@ jobs: QUAY_ROBOT: ${{ vars.QUAY_PUBLISH_USERNAME }} run: | set -euo pipefail - oidc=$(curl -sSf -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL" | jq -r .value) + oidc=$(curl -sSf -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=quay" | jq -r .value) echo "::add-mask::$oidc" token=$(curl -sSf -u "$QUAY_ROBOT:$oidc" https://quay.io/oauth2/federation/robot/token | jq -r .token) echo "::add-mask::$token" From abc163855aae0be796d556be0593092ec5378564 Mon Sep 17 00:00:00 2001 From: Kim Gustyr Date: Thu, 3 Dec 2026 19:03:34 +0100 Subject: [PATCH 3/3] ci: Select the publish target by environment and read registry details from it The reusable publish workflow takes environment (dockerhub or quay) and a short target-image name instead of target-registry-url and full image names. REGISTRY, REGISTRY_NAMESPACE and REGISTRY_USERNAME come from the environment's variables. --- .../workflows/.reusable-docker-publish.yml | 33 ++++++++++--------- .../mcp-docker-build-publish-deploy.yml | 7 ++-- .../platform-docker-build-test-publish.yml | 27 ++++++++------- 3 files changed, 37 insertions(+), 30 deletions(-) diff --git a/.github/workflows/.reusable-docker-publish.yml b/.github/workflows/.reusable-docker-publish.yml index 83aba5a60a1b..73513453085d 100644 --- a/.github/workflows/.reusable-docker-publish.yml +++ b/.github/workflows/.reusable-docker-publish.yml @@ -8,23 +8,24 @@ on: type: string description: Source image to publish required: true - target-images: + target-image: type: string - description: Target image names + description: Target image name within the environment's registry namespace, e.g. `flagsmith-api` required: true - target-registry-url: + environment: type: string - description: URL of the target docker registry - required: false - default: docker.io + description: >- + GitHub environment to publish from: `dockerhub` or `quay`. Its variables set the registry + (`REGISTRY`, `REGISTRY_NAMESPACE`, `REGISTRY_USERNAME`), and its OIDC subject is what the registry trusts. + required: true jobs: publish: - name: Publish ${{ inputs.source-images }} to ${{ inputs.target-images }} + name: Publish ${{ inputs.source-images }} to ${{ inputs.environment }}/${{ inputs.target-image }} runs-on: depot-ubuntu-latest - # Each registry's OIDC trust matches this environment's subject (quay or dockerhub); + # The registry's OIDC trust matches this environment's subject; # the environment's deployment rules limit which refs can publish. - environment: ${{ inputs.target-registry-url == 'quay.io' && 'quay' || 'dockerhub' }} + environment: ${{ inputs.environment }} permissions: contents: read @@ -46,18 +47,18 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Login to Docker Hub - if: inputs.target-registry-url == 'docker.io' + if: vars.REGISTRY == 'docker.io' uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0 env: DOCKERHUB_OIDC_CONNECTIONID: ${{ vars.DOCKERHUB_OIDC_CONNECTIONID }} with: - username: flagsmith + username: ${{ vars.REGISTRY_USERNAME }} - name: Get a short-lived Quay robot token id: quay - if: inputs.target-registry-url == 'quay.io' + if: vars.REGISTRY == 'quay.io' env: - QUAY_ROBOT: ${{ vars.QUAY_PUBLISH_USERNAME }} + QUAY_ROBOT: ${{ vars.REGISTRY_USERNAME }} run: | set -euo pipefail oidc=$(curl -sSf -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=quay" | jq -r .value) @@ -68,17 +69,17 @@ jobs: - name: Login to Quay uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0 - if: inputs.target-registry-url == 'quay.io' + if: vars.REGISTRY == 'quay.io' with: registry: quay.io - username: ${{ vars.QUAY_PUBLISH_USERNAME }} + username: ${{ vars.REGISTRY_USERNAME }} password: ${{ steps.quay.outputs.token }} - name: Docker metadata id: meta uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0 with: - images: ${{ inputs.target-images }} + images: ${{ vars.REGISTRY }}/${{ vars.REGISTRY_NAMESPACE }}/${{ inputs.target-image }} tags: | type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} diff --git a/.github/workflows/mcp-docker-build-publish-deploy.yml b/.github/workflows/mcp-docker-build-publish-deploy.yml index 4b6f7cb918b8..782e5a894ab7 100644 --- a/.github/workflows/mcp-docker-build-publish-deploy.yml +++ b/.github/workflows/mcp-docker-build-publish-deploy.yml @@ -51,8 +51,9 @@ jobs: uses: ./.github/workflows/.reusable-docker-publish.yml if: github.event_name == 'release' with: + environment: dockerhub source-images: ${{ needs.docker-build-mcp.outputs.image }} - target-images: flagsmith/flagsmith-mcp + target-image: flagsmith-mcp secrets: inherit # Publish to Quay.io @@ -66,9 +67,9 @@ jobs: uses: ./.github/workflows/.reusable-docker-publish.yml if: github.event_name == 'release' with: - target-registry-url: quay.io + environment: quay source-images: ${{ needs.docker-build-mcp.outputs.image }} - target-images: quay.io/${{ vars.QUAY_ORGANISATION_NAME }}/flagsmith-mcp + target-image: flagsmith-mcp secrets: inherit # Publish to staging Amazon ECR on every push to main diff --git a/.github/workflows/platform-docker-build-test-publish.yml b/.github/workflows/platform-docker-build-test-publish.yml index ae86f30aaa4c..56a40dd08ec8 100644 --- a/.github/workflows/platform-docker-build-test-publish.yml +++ b/.github/workflows/platform-docker-build-test-publish.yml @@ -163,8 +163,9 @@ jobs: uses: ./.github/workflows/.reusable-docker-publish.yml if: github.event_name == 'release' with: + environment: dockerhub source-images: ${{ needs.docker-build-api.outputs.image }} - target-images: flagsmith/flagsmith-api + target-image: flagsmith-api secrets: inherit docker-publish-frontend: @@ -176,8 +177,9 @@ jobs: uses: ./.github/workflows/.reusable-docker-publish.yml if: github.event_name == 'release' with: + environment: dockerhub source-images: ${{ needs.docker-build-frontend.outputs.image }} - target-images: flagsmith/flagsmith-frontend + target-image: flagsmith-frontend secrets: inherit docker-publish-unified: @@ -189,8 +191,9 @@ jobs: uses: ./.github/workflows/.reusable-docker-publish.yml if: github.event_name == 'release' with: + environment: dockerhub source-images: ${{ needs.docker-build-unified.outputs.image }} - target-images: flagsmith/flagsmith + target-image: flagsmith secrets: inherit docker-publish-private-cloud-api: @@ -202,8 +205,9 @@ jobs: uses: ./.github/workflows/.reusable-docker-publish.yml if: github.event_name == 'release' with: + environment: dockerhub source-images: ${{ needs.docker-build-private-cloud-api.outputs.image }} - target-images: flagsmith/flagsmith-private-cloud-api + target-image: flagsmith-private-cloud-api secrets: inherit docker-publish-private-cloud: @@ -215,8 +219,9 @@ jobs: uses: ./.github/workflows/.reusable-docker-publish.yml if: github.event_name == 'release' with: + environment: dockerhub source-images: ${{ needs.docker-build-private-cloud.outputs.image }} - target-images: flagsmith/flagsmith-private-cloud + target-image: flagsmith-private-cloud secrets: inherit # Publish to Quay.io @@ -230,9 +235,9 @@ jobs: uses: ./.github/workflows/.reusable-docker-publish.yml if: github.event_name == 'release' with: - target-registry-url: quay.io + environment: quay source-images: ${{ needs.docker-build-private-cloud.outputs.image }} - target-images: quay.io/${{ vars.QUAY_ORGANISATION_NAME }}/flagsmith-enterprise + target-image: flagsmith-enterprise secrets: inherit docker-publish-quay-enterprise-api: @@ -244,9 +249,9 @@ jobs: uses: ./.github/workflows/.reusable-docker-publish.yml if: github.event_name == 'release' with: - target-registry-url: quay.io + environment: quay source-images: ${{ needs.docker-build-private-cloud-api.outputs.image }} - target-images: quay.io/${{ vars.QUAY_ORGANISATION_NAME }}/flagsmith-enterprise-api + target-image: flagsmith-enterprise-api secrets: inherit docker-publish-quay-frontend: @@ -258,7 +263,7 @@ jobs: uses: ./.github/workflows/.reusable-docker-publish.yml if: github.event_name == 'release' with: - target-registry-url: quay.io + environment: quay source-images: ${{ needs.docker-build-frontend.outputs.image }} - target-images: quay.io/${{ vars.QUAY_ORGANISATION_NAME }}/flagsmith-frontend + target-image: flagsmith-frontend secrets: inherit