Skip to content

Actually add docker support, fix lowercase in docker publish #2

Actually add docker support, fix lowercase in docker publish

Actually add docker support, fix lowercase in docker publish #2

name: Build & Publish Docker Image
on:
push:
branches:
- main
tags:
- "v*.*.*"
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: dromeport # lowercase
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- 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 Docker metadata (tags & labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/sensor0x0/${{ env.IMAGE_NAME }}
tags: |
# tag semver releases as vX.Y.Z and vX.Y
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
# tag branch pushes as the branch name (main → latest)
type=ref,event=branch
# always tag the default branch as "latest"
type=raw,value=latest,enable={{is_default_branch}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/sensor0x0/${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/sensor0x0/${{ env.IMAGE_NAME }}:buildcache,mode=max