Skip to content

Build & publish images to GHCR #446

Build & publish images to GHCR

Build & publish images to GHCR #446

Workflow file for this run

name: Build & publish images to GHCR
on:
workflow_dispatch:
inputs:
version:
description: 'Version to tag the images (e.g., 1.0.0)'
required: true
type: string
latest:
description: 'Also tag as latest'
required: false
type: boolean
default: false
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- dockerfile: ./Dockerfile.kaneo
image: ghcr.io/${{ github.repository_owner }}/kaneo
- dockerfile: ./apps/web/Dockerfile
image: ghcr.io/${{ github.repository_owner }}/web
- dockerfile: ./apps/api/Dockerfile
image: ghcr.io/${{ github.repository_owner }}/api
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GH_PACKAGE_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ matrix.image }}
tags: |
type=raw,value=${{ inputs.version }}
type=raw,value=latest,enable=${{ inputs.latest }}
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
file: ${{ matrix.dockerfile }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
trigger-helm-publish:
needs: build-and-push-image
if: inputs.version != '' && github.ref == 'refs/heads/main'
runs-on: ubuntu-24.04
permissions:
actions: write
steps:
- name: Trigger Helm chart publish
uses: actions/github-script@v8
env:
VERSION: ${{ inputs.version }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const version = process.env.VERSION;
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'helm-chart.yml',
ref: 'main',
inputs: {
version: version
}
});
console.log(`Triggered Helm chart publish for version ${version}`);