Skip to content

Kernel Indexer Build and Push #9

Kernel Indexer Build and Push

Kernel Indexer Build and Push #9

name: Kernel Indexer Build and Push
on:
push:
branches: [ main, develop ]
paths:
- 'kernel-indexer/**'
- 'kernel_indexer'
- '.github/workflows/docker-build-indexer.yml'
pull_request:
branches: [ main, develop ]
paths:
- 'kernel-indexer/**'
- 'kernel_indexer'
- '.github/workflows/docker-build-indexer.yml'
workflow_dispatch:
env:
REGISTRY: docker.io
IMAGE_NAME: ${{ secrets.DOCKERHUB_REPO }}/icrn-kernel-indexer
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
id: build
uses: docker/build-push-action@v5
with:
context: .
file: kernel-indexer/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Output image info
run: |
echo "Built and pushed image: ${{ steps.meta.outputs.tags }}"
echo "Image digest: ${{ steps.build.outputs.digest }}"