Files
fastnetmon-rewritten/.github/workflows/publish-docker.yml

71 lines
1.9 KiB
YAML

name: Publish Docker image
on:
push:
branches:
- master
schedule:
# Daily rebuild at 04:00 UTC to pick up base image and dependency updates
- cron: "0 4 * * *"
workflow_dispatch:
inputs:
version:
description: "FastNetMon build version tag (in addition to :latest)"
required: false
default: "1.2.10"
permissions:
contents: read
packages: write
env:
# Keep in sync with .circleci/config.yml `fastnetmon_build_version`.
DEFAULT_VERSION: "1.2.10"
REGISTRY: ghcr.io
jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Resolve image name and version
id: meta
run: |
owner_lc="${GITHUB_REPOSITORY_OWNER,,}"
version="${{ github.event.inputs.version }}"
if [ -z "$version" ]; then
version="${DEFAULT_VERSION}"
fi
image="${REGISTRY}/${owner_lc}/fastnetmon-community"
echo "image=$image" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "Will build $image:$version and $image:latest"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push multi-arch image
uses: docker/build-push-action@v6
with:
context: .
file: src/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ steps.meta.outputs.image }}:${{ steps.meta.outputs.version }}
${{ steps.meta.outputs.image }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max