watchparty/.forgejo/workflows/publish-docker.yml
Nicolas 64710fa779
All checks were successful
Publier l'image Docker / publish (push) Successful in 28s
Add Forgejo Actions pipeline to build/publish the Docker image
Mirrors the working mediaDrop pipeline (.forgejo/workflows/publish-docker.yml
there) on the same instance: push to master -> latest + short-sha tags,
push a vX.Y.Z tag -> X.Y.Z/X.Y/latest. REGISTRY_TOKEN secret already
present on this repo. No test job yet - nothing to test.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-13 20:59:55 +02:00

102 lines
3.6 KiB
YAML

# Build et publie l'image Docker de Watch Party sur le registre de
# conteneurs Forgejo :
# git.dev.kyuno.fr/kyuno/watchparty
#
# - push sur `master` -> tags `latest` + `<sha court>`
# - push d'un tag `vX.Y.Z` -> tags `X.Y.Z`, `X.Y`, `latest`
# - déclenchement manuel possible (Actions -> Run workflow)
#
# Repris de mediaDrop (.forgejo/workflows/publish-docker.yml) - mêmes
# prérequis côté instance :
# 1. Actions activé pour le dépôt : Settings -> Actions -> Enable.
# 2. Un runner enregistré avec le label `ubuntu-latest`, capable de lancer
# `docker` dans les jobs conteneurisés (socket hôte monté dans le
# runner - voir la config qui fait déjà tourner mediaDrop).
# 3. Registre : secret REGISTRY_TOKEN (déjà présent sur CE dépôt au moment
# où ce fichier a été écrit) - un jeton avec les scopes write:package/
# read:package (Forgejo -> Settings -> Applications), le jeton
# automatique de l'Action n'a pas ce droit.
#
# Pas de job de test : ce projet n'a pas de suite de tests pour l'instant
# (contrairement à mediaDrop) - à ajouter ici le jour où il y en a une.
name: Publier l'image Docker
on:
push:
branches: [master]
tags: ['v*']
workflow_dispatch:
permissions:
contents: read
packages: write
env:
REGISTRY: git.dev.kyuno.fr
IMAGE: git.dev.kyuno.fr/${{ github.repository_owner }}/watchparty
jobs:
publish:
runs-on: ubuntu-latest
container:
image: docker:27-cli
steps:
# `docker:27-cli` (Alpine) n'a pas Node : pas d'actions/checkout
# (action JS) possible ici. Clone Git direct du dépôt, comme mediaDrop.
- name: Récupérer les sources
run: |
set -eu
apk add --no-cache git
git init -q
git remote add origin "${{ github.server_url }}/${{ github.repository }}.git"
git fetch -q --depth 1 origin "${{ github.ref_name }}"
git checkout -q FETCH_HEAD
- name: Calculer les tags
id: tags
run: |
set -eu
if [ "${{ github.ref_type }}" = "tag" ]; then
v="${{ github.ref_name }}"
v="${v#v}"
list="${IMAGE}:${v} ${IMAGE}:${v%.*} ${IMAGE}:latest"
else
short="$(echo "${{ github.sha }}" | cut -c1-12)"
list="${IMAGE}:latest ${IMAGE}:${short}"
fi
echo "list=${list}" >> "$GITHUB_OUTPUT"
echo "Tags : ${list}"
- name: Connexion au registre
run: |
set -eu
if [ -z "${{ secrets.REGISTRY_TOKEN }}" ]; then
echo "Secret REGISTRY_TOKEN manquant (voir l'en-tête du workflow)." >&2
exit 1
fi
echo "${{ secrets.REGISTRY_TOKEN }}" | \
docker login "$REGISTRY" -u "${{ github.repository_owner }}" --password-stdin
- name: Build
run: |
set -eu
args=""
for t in ${{ steps.tags.outputs.list }}; do args="$args -t $t"; done
# Contexte = racine du dépôt (le Dockerfile copie aussi client/) -
# shellcheck disable=SC2086
docker build $args \
-f server/Dockerfile \
--label "org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}" \
--label "org.opencontainers.image.revision=${{ github.sha }}" \
--label "org.opencontainers.image.created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
.
- name: Push
run: |
set -eu
for t in ${{ steps.tags.outputs.list }}; do docker push "$t"; done
- name: Déconnexion
if: always()
run: docker logout "$REGISTRY"