5
5
- cron : ' 15 0 * * *'
6
6
workflow_dispatch :
7
7
8
-
9
8
concurrency :
10
9
group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11
10
cancel-in-progress : true
12
11
13
12
env :
14
13
image : ghcr.io/dragonflydb/dragonfly-dev
14
+ GCS_IMAGE : us-central1-docker.pkg.dev/dragonflydb-public/dragonfly-registry/dragonfly-dev
15
15
16
16
jobs :
17
17
build_and_tag :
@@ -36,14 +36,16 @@ jobs:
36
36
with :
37
37
fetch-depth : 1
38
38
submodules : true
39
+
39
40
- name : Set up Docker Buildx
40
41
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
43
45
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
+
47
49
- name : Get Build Information
48
50
id : build_info
49
51
run : |
55
57
with :
56
58
images : |
57
59
${{ env.image }}
60
+ ${{ env.GCS_IMAGE }}
58
61
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
60
63
labels : |
61
64
org.opencontainers.image.vendor=DragonflyDB LTD
62
65
org.opencontainers.image.title=Dragonfly Development Image
@@ -77,25 +80,23 @@ jobs:
77
80
load : true # Load the build images into the local docker.
78
81
- name : Test Image
79
82
run : |
80
- image_tag=${{ steps.metadata.outputs.tags }}
81
83
echo ${{ steps.build.outputs.digest }}
82
- image_digest= ${{ env.image }}@${{ steps.build .outputs.digest }}
83
-
84
+ image_tags=( ${{ steps.metadata .outputs.tags }})
85
+
84
86
# install redis-tools
85
87
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
99
100
100
101
outputs :
101
102
# matrix jobs outputs override each other, but we use the same sha
@@ -109,23 +110,36 @@ jobs:
109
110
matrix :
110
111
flavor : [alpine,ubuntu]
111
112
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
114
118
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
+
119
122
- name : Merge and Push
120
123
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