2222 GOBIN : /home/runner/go/bin
2323 GOPROXY : " https://proxy.golang.org"
2424 REGISTRY_IMAGE : ghcr.io/pluralsh/cloud-query
25+ REGISTRY_IMAGE_DB : ghcr.io/pluralsh/cloud-query-db
2526 DOCKER_METADATA_PR_HEAD_SHA : ' true'
2627jobs :
2728 test :
4445 run : go mod download
4546 - name : Test
4647 run : PATH=$PATH:$GOPATH/bin make test
47- build-image :
48- name : Build image
48+ build-db :
49+ name : Build db image
4950 needs : [ test ]
5051 permissions :
5152 contents : ' read'
6061 - platform : linux/arm64
6162 runner : ubuntu-24.04-arm
6263 runs-on : ${{ matrix.platforms.runner }}
64+ defaults :
65+ run :
66+ shell : bash
67+ working-directory : go/cloud-query
68+ steps :
69+ - name : Checkout
70+ uses : actions/checkout@v4
71+ with :
72+ fetch-depth : 0
73+ - name : Prepare
74+ run : |
75+ platform=${{ matrix.platforms.platform }}
76+ echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
77+ - name : Docker meta
78+ id : meta
79+ uses : docker/metadata-action@v5
80+ with :
81+ images : ${{ env.REGISTRY_IMAGE_DB }}
82+ - name : Login to GHCR
83+ uses : docker/login-action@v3
84+ with :
85+ registry : ghcr.io
86+ username : ${{ github.repository_owner }}
87+ password : ${{ secrets.GITHUB_TOKEN }}
88+ - uses : google-github-actions/auth@v1
89+ with :
90+ workload_identity_provider : ' projects/${{ secrets.GOOGLE_PROJECT_ID }}/locations/global/workloadIdentityPools/github/providers/github'
91+ service_account :
' [email protected] ' 92+ token_format : ' access_token'
93+ create_credentials_file : true
94+ -
uses :
google-github-actions/[email protected] 95+ - name : Login to GCR
96+ run : gcloud auth configure-docker -q
97+ - name : Login to Docker
98+ uses : docker/login-action@v3
99+ with :
100+ username : mjgpluralsh
101+ password : ${{ secrets.DOCKER_ACCESS_TOKEN }}
102+ - name : Set up QEMU
103+ uses : docker/setup-qemu-action@v3
104+ - name : Set up Docker Buildx
105+ 106+ - name : Build and push by digest
107+ id : build
108+ uses : docker/build-push-action@v6
109+ with :
110+ context : " ./go/cloud-query"
111+ file : " ./go/cloud-query/db.Dockerfile"
112+ tags : ${{ env.REGISTRY_IMAGE_DB }}
113+ labels : ${{ steps.meta.outputs.labels }}
114+ platforms : ${{ matrix.platforms.platform }}
115+ outputs : type=image,push-by-digest=true,name-canonical=true,push=true
116+ cache-from : type=gha
117+ cache-to : type=gha,mode=max
118+ build-args : |
119+ GIT_COMMIT=${{ github.sha }}
120+ VERSION=${{ steps.meta.outputs.version }}
121+ - name : Export digest
122+ run : |
123+ mkdir -p ${{ runner.temp }}/digests
124+ digest="${{ steps.build.outputs.digest }}"
125+ touch "${{ runner.temp }}/digests/${digest#sha256:}"
126+ - name : Upload digest
127+ uses : actions/upload-artifact@v4
128+ with :
129+ name : digests-db-${{ env.PLATFORM_PAIR }}-${{ github.run_id }}
130+ path : ${{ runner.temp }}/digests/*
131+ if-no-files-found : error
132+ retention-days : 1
133+ build-cloud-query :
134+ name : Build cloud-query image
135+ needs : [test]
136+ permissions :
137+ contents : ' read'
138+ id-token : ' write'
139+ packages : ' write'
140+ strategy :
141+ fail-fast : false
142+ matrix :
143+ platforms :
144+ - platform : linux/amd64
145+ runner : ubuntu-24.04
146+ - platform : linux/arm64
147+ runner : ubuntu-24.04-arm
148+ runs-on : ${{ matrix.platforms.runner }}
63149 defaults :
64150 run :
65151 shell : bash
@@ -125,13 +211,76 @@ jobs:
125211 - name : Upload digest
126212 uses : actions/upload-artifact@v4
127213 with :
128- name : digests-${{ env.PLATFORM_PAIR }}
214+ name : digests-cloudquery- ${{ env.PLATFORM_PAIR }}-${{ github.run_id }}
129215 path : ${{ runner.temp }}/digests/*
130216 if-no-files-found : error
131217 retention-days : 1
132- publish-image :
133- name : Publish image
134- needs : [ build-image ]
218+ publish-db :
219+ name : Publish db image
220+ needs : [build-db]
221+ permissions :
222+ contents : ' read'
223+ id-token : ' write'
224+ packages : ' write'
225+ strategy :
226+ fail-fast : false
227+ matrix :
228+ images :
229+ - ghcr.io/pluralsh/cloud-query-db
230+ - gcr.io/pluralsh/cloud-query-db
231+ - docker.io/pluralsh/cloud-query-db
232+ runs-on : ubuntu-latest
233+ steps :
234+ - name : Download digests
235+ uses : actions/download-artifact@v4
236+ with :
237+ path : ${{ runner.temp }}/digests
238+ pattern : digests-db-*
239+ merge-multiple : true
240+ - name : Login to GHCR
241+ uses : docker/login-action@v3
242+ with :
243+ registry : ghcr.io
244+ username : ${{ github.repository_owner }}
245+ password : ${{ secrets.GITHUB_TOKEN }}
246+ - uses : google-github-actions/auth@v1
247+ with :
248+ workload_identity_provider : ' projects/${{ secrets.GOOGLE_PROJECT_ID }}/locations/global/workloadIdentityPools/github/providers/github'
249+ service_account :
' [email protected] ' 250+ token_format : ' access_token'
251+ create_credentials_file : true
252+ -
uses :
google-github-actions/[email protected] 253+ - name : Login to GCR
254+ run : gcloud auth configure-docker -q
255+ - name : Login to Docker Hub
256+ uses : docker/login-action@v3
257+ with :
258+ username : mjgpluralsh
259+ password : ${{ secrets.DOCKER_ACCESS_TOKEN }}
260+ - name : Set up Docker Buildx
261+ uses : docker/setup-buildx-action@v3
262+ - name : Docker meta
263+ id : meta
264+ uses : docker/metadata-action@v5
265+ with :
266+ images : ${{ matrix.images }}
267+ tags : |
268+ type=ref,event=branch
269+ type=ref,event=tag
270+ type=ref,event=pr
271+ type=sha
272+ type=raw,value=${{ github.event.inputs.version }},enable=${{ github.event.inputs.version != '' }}
273+ - name : Create manifest list and push
274+ working-directory : ${{ runner.temp }}/digests
275+ run : |
276+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
277+ $(printf '${{ env.REGISTRY_IMAGE_DB }}@sha256:%s ' *)
278+ - name : Inspect image
279+ run : |
280+ docker buildx imagetools inspect ${{ matrix.images }}:${{ steps.meta.outputs.version }}
281+ publish-cloud-query :
282+ name : Publish cloud-query image
283+ needs : [build-cloud-query]
135284 permissions :
136285 contents : ' read'
137286 id-token : ' write'
@@ -149,7 +298,7 @@ jobs:
149298 uses : actions/download-artifact@v4
150299 with :
151300 path : ${{ runner.temp }}/digests
152- pattern : digests-*
301+ pattern : digests-cloudquery- *
153302 merge-multiple : true
154303 - name : Login to GHCR
155304 uses : docker/login-action@v3
@@ -191,4 +340,4 @@ jobs:
191340 $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
192341 - name : Inspect image
193342 run : |
194- docker buildx imagetools inspect ${{ matrix.images }}:${{ steps.meta.outputs.version }}
343+ docker buildx imagetools inspect ${{ matrix.images }}:${{ steps.meta.outputs.version }}
0 commit comments