Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions .github/workflows/docker-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: CI/CD — Build and Publish Probe Image

on:
push:
branches: [main]
paths:
- '**.go'
- go.mod
- go.sum
- Dockerfile
- .github/workflows/docker-publish.yaml
pull_request:
branches: [main]
paths:
- '**.go'
- go.mod
- go.sum
- Dockerfile
- .github/workflows/docker-publish.yaml
workflow_dispatch: {}

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
ci:
name: Lint and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.24"
- uses: golangci/golangci-lint-action@v6
with:
version: latest
- run: go test ./... -race

build-and-push:
name: Build and push Probe Docker image
needs: ci
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha
type=raw,value=dev
type=raw,value=latest,enable={{is_default_branch}}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max

deploy:
name: Deploy to ${{ matrix.environment }}
needs: build-and-push
if: github.event_name == 'push'
runs-on: ubuntu-latest
strategy:
matrix:
environment: >-
${{
github.ref == 'refs/heads/main'
&& fromJSON('["dev","prd"]')
|| fromJSON('["dev"]')
}}
steps:
- name: Trigger infra deployment
uses: peter-evans/repository-dispatch@v4
with:
token: ${{ secrets.INFRA_DEPLOY_PAT }}
repository: KrakenKey/infra-int
event-type: image-published
client-payload: >-
{"image": "${{ env.IMAGE_NAME }}", "sha": "${{ github.sha }}", "ref": "${{ github.ref_name }}", "environment": "${{ matrix.environment }}"}
Loading