65 lines
1.9 KiB
YAML
65 lines
1.9 KiB
YAML
# Copyright (C) 2026 ysicing
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
name: Server image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- '**'
|
|
paths:
|
|
- server/**
|
|
- .github/workflows/server-image.yml
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Generate image name and tag
|
|
id: image
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
raw_branch="$GITHUB_REF_NAME"
|
|
branch="$(printf '%s' "$raw_branch" \
|
|
| tr '[:upper:]' '[:lower:]' \
|
|
| sed -E 's/[^a-z0-9_.-]+/-/g; s/-+/-/g; s/^[.-]+//; s/[.-]+$//' \
|
|
| cut -c1-80)"
|
|
if [ -z "$branch" ]; then branch=detached; fi
|
|
image="ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/xstats-server"
|
|
tag="${branch}-${GITHUB_SHA}"
|
|
echo "image=$image" >> "$GITHUB_OUTPUT"
|
|
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
|
echo "### Container image" >> "$GITHUB_STEP_SUMMARY"
|
|
echo "\`$image:$tag\`" >> "$GITHUB_STEP_SUMMARY"
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to GHCR
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build and publish
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: server/api/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.image.outputs.image }}:${{ steps.image.outputs.tag }}
|
|
labels: |
|
|
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
|
|
org.opencontainers.image.revision=${{ github.sha }}
|
|
cache-from: type=gha,scope=xstats-server
|
|
cache-to: type=gha,mode=max,scope=xstats-server
|