Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 32 additions & 27 deletions .github/workflows/.reusable-docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +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
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: ''
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
# The registry's OIDC trust matches this environment's subject; its deployment rules limit which refs can publish.
environment: ${{ inputs.target-registry-url == 'docker.io' && 'dockerhub' || '' }}
# The registry's OIDC trust matches this environment's subject;
# the environment's deployment rules limit which refs can publish.
environment: ${{ inputs.environment }}

permissions:
contents: read
Expand All @@ -55,26 +47,39 @@ 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: vars.REGISTRY == 'quay.io'
env:
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)
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 ${{ inputs.target-registry-url }}
if: inputs.target-registry-url != 'docker.io'
- name: Login to Quay
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
if: vars.REGISTRY == 'quay.io'
with:
registry: ${{ inputs.target-registry-url }}
username: ${{ inputs.docker-username }}
password: ${{ secrets[inputs.docker-password-secret-name] }}
registry: quay.io
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}}
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/mcp-docker-build-publish-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -66,11 +67,9 @@ jobs:
uses: ./.github/workflows/.reusable-docker-publish.yml
if: github.event_name == 'release'
with:
target-registry-url: quay.io
docker-username: ${{ vars.QUAY_PUBLISH_USERNAME }}
docker-password-secret-name: QUAY_PUBLISH_PASSWORD
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
Expand Down
33 changes: 16 additions & 17 deletions .github/workflows/platform-docker-build-test-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -230,11 +235,9 @@ jobs:
uses: ./.github/workflows/.reusable-docker-publish.yml
if: github.event_name == 'release'
with:
target-registry-url: quay.io
docker-username: ${{ vars.QUAY_PUBLISH_USERNAME }}
docker-password-secret-name: QUAY_PUBLISH_PASSWORD
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:
Expand All @@ -246,11 +249,9 @@ jobs:
uses: ./.github/workflows/.reusable-docker-publish.yml
if: github.event_name == 'release'
with:
target-registry-url: quay.io
docker-username: ${{ vars.QUAY_PUBLISH_USERNAME }}
docker-password-secret-name: QUAY_PUBLISH_PASSWORD
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:
Expand All @@ -262,9 +263,7 @@ jobs:
uses: ./.github/workflows/.reusable-docker-publish.yml
if: github.event_name == 'release'
with:
target-registry-url: quay.io
docker-username: ${{ vars.QUAY_PUBLISH_USERNAME }}
docker-password-secret-name: QUAY_PUBLISH_PASSWORD
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
Loading