Skip to content

Publish Docker Image #2

Publish Docker Image

Publish Docker Image #2

Workflow file for this run

name: Publish Docker Image
on:
release:
types: [published]
# Allow manual trigger for testing
workflow_dispatch:
inputs:
tag:
description: 'Image tag (defaults to "dev")'
required: false
default: 'dev'
env:
REGISTRY: ghcr.io
IMAGE_NAME: agent-ci/agentexec-worker
permissions:
contents: read
packages: write
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# Tag with version on release (e.g., v0.1.2 -> 0.1.2)
type=semver,pattern={{version}}
# Tag with major.minor on release (e.g., v0.1.2 -> 0.1)
type=semver,pattern={{major}}.{{minor}}
# Tag as "latest" on release
type=raw,value=latest,enable=${{ github.event_name == 'release' }}
# Tag with input value on manual dispatch
type=raw,value=${{ inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./docker
file: ./docker/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64