Skip to content

Commit b926325

Browse files
download image on release
1 parent b3c632a commit b926325

File tree

2 files changed

+66
-3
lines changed

2 files changed

+66
-3
lines changed

.github/actions/push-docker/action.yml

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: "Docker Push"
2-
description: "Builds and pushes a Docker image with specified tags"
2+
description: "Builds and pushes a Docker image with specified tags, or pulls from source registry and re-tags"
33
inputs:
44
version_tag:
55
description: "The primary version tag for the image (e.g., 1.0.0)"
@@ -14,6 +14,14 @@ inputs:
1414
docker_password:
1515
description: "Docker Hub password"
1616
required: true
17+
source_registry:
18+
description: "Source registry to pull from (e.g., ECR). If provided, will pull and re-tag instead of building"
19+
required: false
20+
default: ""
21+
source_image_tag:
22+
description: "Source image tag to pull (without platform suffix). Required if source_registry is provided"
23+
required: false
24+
default: ""
1725

1826
runs:
1927
using: "composite"
@@ -42,7 +50,45 @@ runs:
4250
echo "TAGS_LIST=$tags" >> $GITHUB_OUTPUT
4351
echo "Prepared tags: $tags"
4452
53+
- name: Pull from Source and Push to DockerHub
54+
if: inputs.source_registry != ''
55+
shell: bash
56+
run: |
57+
source_image="${{ inputs.source_registry }}/solace-agent-mesh:${{ inputs.source_image_tag }}"
58+
59+
echo "Pulling multi-platform image from ECR: ${source_image}"
60+
61+
# Pull the multi-platform manifest and both platform images
62+
docker pull --platform linux/amd64 "${source_image}-amd64"
63+
docker pull --platform linux/arm64 "${source_image}-arm64"
64+
65+
# Convert comma-separated tags to array
66+
IFS=',' read -ra TAGS <<< "${{ steps.docker_tags.outputs.TAGS_LIST }}"
67+
68+
# For each target tag, create a multi-platform manifest
69+
for TAG in "${TAGS[@]}"; do
70+
TAG=$(echo "$TAG" | xargs) # Trim whitespace
71+
echo "Creating multi-platform manifest for: ${TAG}"
72+
73+
# Tag the platform-specific images for DockerHub
74+
docker tag "${source_image}-amd64" "${TAG}-amd64"
75+
docker tag "${source_image}-arm64" "${TAG}-arm64"
76+
77+
# Push platform-specific images
78+
docker push "${TAG}-amd64"
79+
docker push "${TAG}-arm64"
80+
81+
# Create and push multi-platform manifest
82+
docker buildx imagetools create \
83+
--tag "${TAG}" \
84+
"${TAG}-amd64" \
85+
"${TAG}-arm64"
86+
done
87+
88+
echo "Successfully pulled from ECR and pushed to DockerHub"
89+
4590
- name: Build And Push Docker Image
91+
if: inputs.source_registry == ''
4692
uses: docker/build-push-action@v6.16.0
4793
with:
4894
context: "."

.github/workflows/release.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
MANIFEST_AWS_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
5050

5151
build_and_push_docker:
52-
name: Build and Push Docker Image
52+
name: Pull from ECR and Push to DockerHub
5353
needs: release
5454
runs-on: ubuntu-latest
5555
steps:
@@ -58,10 +58,27 @@ jobs:
5858
with:
5959
ref: ${{ needs.release.outputs.commit_hash }}
6060

61-
- name: Build and Push Docker Image to DockerHub
61+
- name: Get Commit Hash
62+
id: get_commit_hash
63+
run: |
64+
echo "short_sha=$(git rev-parse HEAD | cut -c1-10)" >> $GITHUB_OUTPUT
65+
66+
- name: Configure AWS credentials
67+
uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1
68+
with:
69+
aws-access-key-id: ${{ secrets.SAM_AWS_ACCESS_KEY_ID }}
70+
aws-secret-access-key: ${{ secrets.SAM_AWS_SECRET_ACCESS_KEY }}
71+
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
72+
73+
- name: Login to Amazon ECR
74+
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
75+
76+
- name: Pull from ECR and Push to DockerHub
6277
uses: ./.github/actions/push-docker
6378
with:
6479
version_tag: ${{ needs.release.outputs.new_version }}
6580
push_latest: true
6681
docker_username: ${{ secrets.DOCKER_USERNAME }}
6782
docker_password: ${{ secrets.DOCKER_PASSWORD }}
83+
source_registry: ${{ secrets.SAM_AWS_ECR_REGISTRY }}
84+
source_image_tag: ${{ needs.release.outputs.new_version }}-${{ steps.get_commit_hash.outputs.short_sha }}

0 commit comments

Comments
 (0)