55 - cron : ' 15 0 * * *'
66 workflow_dispatch :
77
8-
98concurrency :
109 group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
1110 cancel-in-progress : true
1211
1312env :
1413 image : ghcr.io/dragonflydb/dragonfly-dev
14+ GCS_IMAGE : us-central1-docker.pkg.dev/dragonflydb-public/dragonfly-registry/dragonfly-dev
1515
1616jobs :
1717 build_and_tag :
@@ -36,14 +36,16 @@ jobs:
3636 with :
3737 fetch-depth : 1
3838 submodules : true
39+
3940 - name : Set up Docker Buildx
4041 uses : docker/setup-buildx-action@v3
41- - name : Login to GitHub Container Registry
42- uses : docker/login-action@v3
42+
43+ - name : Login to Registries
44+ uses : ./.github/actions/multi-registry-docker-login
4345 with :
44- registry : ghcr.io
45- username : ${{ github.repository_owner }}
46- password : ${{ secrets.GITHUB_TOKEN }}
46+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
47+ GCP_SA_KEY : ${{ secrets.GCP_SA_KEY }}
48+
4749 - name : Get Build Information
4850 id : build_info
4951 run : |
5557 with :
5658 images : |
5759 ${{ env.image }}
60+ ${{ env.GCS_IMAGE }}
5861 tags : |
59- type=sha,enable=true,prefix=${{ matrix.flavor}}-,suffix=-${{ matrix.os.arch }},format=short
62+ type=sha,enable=true,prefix=${{ matrix.flavor}}-,suffix=-${{ matrix.os.arch }},format=short
6063 labels : |
6164 org.opencontainers.image.vendor=DragonflyDB LTD
6265 org.opencontainers.image.title=Dragonfly Development Image
@@ -77,25 +80,23 @@ jobs:
7780 load : true # Load the build images into the local docker.
7881 - name : Test Image
7982 run : |
80- image_tag=${{ steps.metadata.outputs.tags }}
8183 echo ${{ steps.build.outputs.digest }}
82- image_digest= ${{ env.image }}@${{ steps.build .outputs.digest }}
83-
84+ image_tags=( ${{ steps.metadata .outputs.tags }})
85+
8486 # install redis-tools
8587 sudo apt-get install redis-tools -y
86-
87- docker image inspect ${image_tag}
88- echo "Testing ${{ matrix.flavor }} image"
89-
90- # docker run with port-forwarding
91- docker run -d -p 6379:6379 ${image_tag}
92- sleep 5
93- if [[ $(redis-cli -h localhost ping) != "PONG" ]]; then
94- echo "Redis ping failed"
95- exit 1
96- fi
97- echo "Redis ping succeeded"
98- exit 0
88+
89+ for image_tag in "${image_tags[@]}"; do
90+ echo "Testing image: ${image_tag}"
91+ docker image inspect ${image_tag}
92+ echo "Testing ${{ matrix.flavor }} image"
93+
94+ # docker run with port-forwarding
95+ docker run -d -p 6379:6379 ${image_tag}
96+ sleep 5
97+ redis-cli -h localhost ping | grep -q "PONG" || exit 1
98+ docker stop $(docker ps -q --filter ancestor=${image_tag})
99+ done
99100
100101 outputs :
101102 # matrix jobs outputs override each other, but we use the same sha
@@ -109,23 +110,36 @@ jobs:
109110 matrix :
110111 flavor : [alpine,ubuntu]
111112 steps :
112- - name : Login to GitHub Container Registry
113- uses : docker/login-action@v3
113+ - name : checkout
114+ uses : actions/checkout@v4
115+
116+ - name : Login to Registries
117+ uses : ./.github/actions/multi-registry-docker-login
114118 with :
115- registry : ghcr.io
116- username : ${{ github.repository_owner }}
117- password : ${{ secrets.GITHUB_TOKEN }}
118-
119+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
120+ GCP_SA_KEY : ${{ secrets.GCP_SA_KEY }}
121+
119122 - name : Merge and Push
120123 run : |
121- flavor_tag=${{ env.image }}:${{matrix.flavor}}
122- sha_tag=${flavor_tag}-${{ needs.build_and_tag.outputs.sha }}
123-
124- # Create and push the manifest like dragonfly-dev:alpine-<sha>
125- docker manifest create ${sha_tag} --amend ${sha_tag}-amd64 --amend ${sha_tag}-arm64
126- docker manifest push ${sha_tag}
127-
128- # Create and push the manifest like dragonfly-dev:alpine
129- docker manifest create ${flavor_tag} --amend ${sha_tag}-amd64 --amend ${sha_tag}-arm64
130- docker manifest push ${flavor_tag}
131-
124+ # Function to create and push manifests for a given registry
125+ create_and_push_manifests() {
126+ local registry=$1
127+ local flavor=$2
128+ local sha=$3
129+
130+ # Create and push the manifest like dragonfly-dev:alpine-<sha>
131+ local sha_tag="${registry}:${flavor}-${sha}"
132+ docker manifest create ${sha_tag} --amend ${sha_tag}-amd64 --amend ${sha_tag}-arm64
133+ docker manifest push ${sha_tag}
134+
135+ # Create and push the manifest like dragonfly-dev:alpine
136+ local flavor_tag="${registry}:${flavor}"
137+ docker manifest create ${flavor_tag} --amend ${sha_tag}-amd64 --amend ${sha_tag}-arm64
138+ docker manifest push ${flavor_tag}
139+ }
140+
141+ # GitHub Container Registry manifests
142+ create_and_push_manifests "${{ env.image }}" "${{ matrix.flavor }}" "${{ needs.build_and_tag.outputs.sha }}"
143+
144+ # Google Artifact Registry manifests
145+ create_and_push_manifests "${{ env.GCS_IMAGE }}" "${{ matrix.flavor }}" "${{ needs.build_and_tag.outputs.sha }}"
0 commit comments