diff --git a/.github/actions/infra/serverless-container/redeploy/action.yml b/.github/actions/infra/serverless-container/redeploy/action.yml index 52a94f3..b0f806e 100644 --- a/.github/actions/infra/serverless-container/redeploy/action.yml +++ b/.github/actions/infra/serverless-container/redeploy/action.yml @@ -8,6 +8,9 @@ inputs: container-ids: description: Target Scaleway Serverless container IDs (comma separated) required: true + container-image: + description: Container image reference without tag; only containers using this image are redeployed + required: false # Vendor: Azure azure-client-id: description: Azure client ID for login with an Azure service principal @@ -67,7 +70,25 @@ runs: case "${{ inputs.vendor }}" in scaleway) container_ids="${{ inputs.container-ids }}" + container_image="${{ inputs.container-image }}" + for container_id in ${container_ids//,/ }; do + if [[ -n "$container_image" ]]; then + configured_image="$( + scw container container get "$container_id" \ + region="${{ inputs.scaleway-region }}" \ + -o json \ + | jq -er '.image' + )" + + if [[ "$configured_image" != "$container_image" ]] \ + && [[ "$configured_image" != "$container_image":* ]] \ + && [[ "$configured_image" != "$container_image"@* ]]; then + echo "Skipping Serverless Container $container_id: configured image is $configured_image" + continue + fi + fi + echo "Redeploying Serverless Container: $container_id" scw container container redeploy "$container_id" region="${{ inputs.scaleway-region }}" done diff --git a/.github/workflows/docker-build-and-deploy.yml b/.github/workflows/docker-build-and-deploy.yml index 0832f8a..e0f4f9e 100644 --- a/.github/workflows/docker-build-and-deploy.yml +++ b/.github/workflows/docker-build-and-deploy.yml @@ -189,6 +189,7 @@ jobs: with: vendor: ${{ inputs.vendor }} container-ids: ${{ vars.SERVERLESS_CONTAINER_IDS }} + container-image: ${{ steps.setup.outputs.registry }}/${{ steps.setup.outputs.image }} # Vendor: azure azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} diff --git a/.github/workflows/docker-promote-to-environment.yml b/.github/workflows/docker-promote-to-environment.yml index 8536eed..bb32dc1 100644 --- a/.github/workflows/docker-promote-to-environment.yml +++ b/.github/workflows/docker-promote-to-environment.yml @@ -214,6 +214,7 @@ jobs: with: vendor: ${{ inputs.vendor }} container-ids: ${{ vars.SERVERLESS_CONTAINER_IDS }} + container-image: ${{ steps.setup.outputs.registry }}/${{ steps.setup.outputs.image }} # Vendor: azure azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} diff --git a/Docs/docker-build-and-deploy.md b/Docs/docker-build-and-deploy.md index b45d9f0..d964612 100644 --- a/Docs/docker-build-and-deploy.md +++ b/Docs/docker-build-and-deploy.md @@ -10,7 +10,7 @@ A rollout on a cluster in the given namespace. If kubernetes labels are provided ### Serverless Container Redeploy -A redeploy on one or more existing Serverless Containers. The workflow does not create or update Serverless Container configuration. Every target container must already exist and already be configured to pull an image tag that this workflow publishes. +A redeploy on one or more existing Serverless Containers. The workflow does not create or update Serverless Container configuration. Every target container must already exist and already be configured to pull an image tag that this workflow publishes. For image variants, each build job only redeploys listed containers whose configured image matches that variant's image. For multiple containers, set `SERVERLESS_CONTAINER_IDS` to a comma-separated value such as `web-container-id,api-container-id`. diff --git a/Docs/docker-promote-to-environment.md b/Docs/docker-promote-to-environment.md index 0718bb4..0317ad2 100644 --- a/Docs/docker-promote-to-environment.md +++ b/Docs/docker-promote-to-environment.md @@ -12,7 +12,7 @@ A rollout on a cluster in the given namespace. If kubernetes labels are provided ### Serverless Container Redeploy -A redeploy on one or more existing Serverless Containers. It does not create or update Serverless Container configuration. Every target container must already exist and already be configured to pull the image tag that this workflow publishes. +A redeploy on one or more existing Serverless Containers. It does not create or update Serverless Container configuration. Every target container must already exist and already be configured to pull the image tag that this workflow publishes. For image variants, each promotion job only redeploys listed containers whose configured image matches that variant's image. For multiple containers, set `SERVERLESS_CONTAINER_IDS` to a comma-separated value such as `web-container-id,api-container-id`.