b4/.github/workflows/docker.yml
Daniel Lavrushin 7f59eab476
ci: publish Docker image to both Docker Hub and GHCR
- Add GHCR login and push tags alongside existing Docker Hub
- Add linux/arm/v7 platform support
- Add packages:write permission for GHCR

Co-Authored-By: RemmoDY <remmody@yandex.ru>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 22:17:52 +01:00

73 lines
1.9 KiB
YAML

name: Docker
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Image version tag (e.g., 1.34.0)"
required: true
default: "latest"
permissions:
contents: read
packages: write
env:
DOCKERHUB_IMAGE: lavrushin/b4
GHCR_IMAGE: ghcr.io/${{ github.repository }}
jobs:
docker:
name: Build & Push Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set version
id: version
run: |
if [ "${{ github.event_name }}" = "release" ]; then
VERSION="${{ github.event.release.tag_name }}"
VERSION="${VERSION#v}"
else
VERSION="${{ inputs.version }}"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
build-args: |
VERSION=${{ steps.version.outputs.version }}
tags: |
${{ env.DOCKERHUB_IMAGE }}:latest
${{ env.DOCKERHUB_IMAGE }}:${{ steps.version.outputs.version }}
${{ env.GHCR_IMAGE }}:latest
${{ env.GHCR_IMAGE }}:${{ steps.version.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max