Skip to content

fix chart publishing (#2916) #145

fix chart publishing (#2916)

fix chart publishing (#2916) #145

Workflow file for this run

name: CD / Cloud Query
on:
workflow_dispatch:
inputs:
version:
description: "Version to build"
required: false
default: "latest"
pull_request:
branches:
- 'master'
paths:
- 'go/cloud-query/**'
- '.github/workflows/cloud-query-cd.yaml'
push:
tags:
- 'v*.*.*'
permissions:
contents: read
env:
GOPATH: /home/runner/go
GOBIN: /home/runner/go/bin
GOPROXY: "https://proxy.golang.org"
REGISTRY_IMAGE: ghcr.io/pluralsh/cloud-query
REGISTRY_IMAGE_DB: ghcr.io/pluralsh/cloud-query-db
DOCKER_METADATA_PR_HEAD_SHA: 'true'
jobs:
test:
name: Unit test
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: go/cloud-query
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go/cloud-query/go.mod
cache: true
- name: Download dependencies
run: go mod download
- name: Test
run: PATH=$PATH:$GOPATH/bin make test
build-db:
name: Build db image
needs: [ test ]
permissions:
contents: 'read'
id-token: 'write'
packages: 'write'
strategy:
fail-fast: false
matrix:
platforms:
- platform: linux/amd64
runner: ubuntu-24.04
- platform: linux/arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.platforms.runner }}
defaults:
run:
shell: bash
working-directory: go/cloud-query
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Prepare
run: |
platform=${{ matrix.platforms.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE_DB }}
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: google-github-actions/auth@v1
with:
workload_identity_provider: 'projects/${{ secrets.GOOGLE_PROJECT_ID }}/locations/global/workloadIdentityPools/github/providers/github'
service_account: '[email protected]'
token_format: 'access_token'
create_credentials_file: true
- uses: google-github-actions/[email protected]
- name: Login to GCR
run: gcloud auth configure-docker -q
- name: Login to Docker
uses: docker/login-action@v3
with:
username: mjgpluralsh
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: "./go/cloud-query"
file: "./go/cloud-query/db.Dockerfile"
tags: ${{ env.REGISTRY_IMAGE_DB }}
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ matrix.platforms.platform }}
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
GIT_COMMIT=${{ github.sha }}
VERSION=${{ steps.meta.outputs.version }}
- name: Export digest
run: |
mkdir -p ${{ runner.temp }}/digests
digest="${{ steps.build.outputs.digest }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-db-${{ env.PLATFORM_PAIR }}-${{ github.run_id }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1
build-cloud-query:
name: Build cloud-query image
needs: [test]
permissions:
contents: 'read'
id-token: 'write'
packages: 'write'
strategy:
fail-fast: false
matrix:
platforms:
- platform: linux/amd64
runner: ubuntu-24.04
- platform: linux/arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.platforms.runner }}
defaults:
run:
shell: bash
working-directory: go/cloud-query
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Prepare
run: |
platform=${{ matrix.platforms.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: google-github-actions/auth@v1
with:
workload_identity_provider: 'projects/${{ secrets.GOOGLE_PROJECT_ID }}/locations/global/workloadIdentityPools/github/providers/github'
service_account: '[email protected]'
token_format: 'access_token'
create_credentials_file: true
- uses: google-github-actions/[email protected]
- name: Login to GCR
run: gcloud auth configure-docker -q
- name: Login to Docker
uses: docker/login-action@v3
with:
username: mjgpluralsh
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: "./go/cloud-query"
file: "./go/cloud-query/Dockerfile"
tags: ${{ env.REGISTRY_IMAGE }}
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ matrix.platforms.platform }}
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
GIT_COMMIT=${{ github.sha }}
VERSION=${{ steps.meta.outputs.version }}
- name: Export digest
run: |
mkdir -p ${{ runner.temp }}/digests
digest="${{ steps.build.outputs.digest }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-cloudquery-${{ env.PLATFORM_PAIR }}-${{ github.run_id }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1
publish-db:
name: Publish db image
needs: [build-db]
permissions:
contents: 'read'
id-token: 'write'
packages: 'write'
strategy:
fail-fast: false
matrix:
images:
- ghcr.io/pluralsh/cloud-query-db
- gcr.io/pluralsh/cloud-query-db
- docker.io/pluralsh/cloud-query-db
runs-on: ubuntu-latest
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests
pattern: digests-db-*
merge-multiple: true
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: google-github-actions/auth@v1
with:
workload_identity_provider: 'projects/${{ secrets.GOOGLE_PROJECT_ID }}/locations/global/workloadIdentityPools/github/providers/github'
service_account: '[email protected]'
token_format: 'access_token'
create_credentials_file: true
- uses: google-github-actions/[email protected]
- name: Login to GCR
run: gcloud auth configure-docker -q
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: mjgpluralsh
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.images }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha
type=raw,value=${{ github.event.inputs.version }},enable=${{ github.event.inputs.version != '' }}
- name: Create manifest list and push
working-directory: ${{ runner.temp }}/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE_DB }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ matrix.images }}:${{ steps.meta.outputs.version }}
publish-cloud-query:
name: Publish cloud-query image
needs: [build-cloud-query]
permissions:
contents: 'read'
id-token: 'write'
packages: 'write'
strategy:
fail-fast: false
matrix:
images:
- ghcr.io/pluralsh/cloud-query
- gcr.io/pluralsh/cloud-query
- docker.io/pluralsh/cloud-query
runs-on: ubuntu-latest
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests
pattern: digests-cloudquery-*
merge-multiple: true
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: google-github-actions/auth@v1
with:
workload_identity_provider: 'projects/${{ secrets.GOOGLE_PROJECT_ID }}/locations/global/workloadIdentityPools/github/providers/github'
service_account: '[email protected]'
token_format: 'access_token'
create_credentials_file: true
- uses: google-github-actions/[email protected]
- name: Login to GCR
run: gcloud auth configure-docker -q
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: mjgpluralsh
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.images }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha
type=raw,value=${{ github.event.inputs.version }},enable=${{ github.event.inputs.version != '' }}
- name: Create manifest list and push
working-directory: ${{ runner.temp }}/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ matrix.images }}:${{ steps.meta.outputs.version }}