Add automatic repository owner to image naming
All checks were successful
build-and-deploy / build (push) Successful in 14s
build-and-deploy / deploy (push) Successful in 2s

- Use github.repository_owner in workflow
- Image format: REGISTRY_URL/owner/APP_NAME:latest
- Works automatically with Gitea registry
- Template-friendly: forks use their own owner
- Update documentation with new format
This commit is contained in:
2025-10-12 22:19:20 -06:00
parent 7120d723ad
commit 0f7abc6d48
4 changed files with 13 additions and 7 deletions

View File

@@ -10,7 +10,10 @@
# REGISTRY & DEPLOYMENT
# ===========================================
# URL del registro Docker (sin http:// ni https://)
REGISTRY_URL=registry.ejemplo.com
# Para registry de Gitea: gitea.ejemplo.com
# El owner del repositorio se agrega automáticamente en el workflow
# Imagen final: REGISTRY_URL/owner/APP_NAME:latest
REGISTRY_URL=gitea.ejemplo.com
# Nombre de la aplicación (usado para container, imagen, y labels de Traefik)
APP_NAME=mi-app

View File

@@ -23,9 +23,9 @@ jobs:
- name: Build+push ${{ vars.APP_NAME }}
run: |
cd nuxt4
docker build -t $REG/$APP_NAME:${{ github.sha }} -t $REG/$APP_NAME:latest .
docker push $REG/$APP_NAME:${{ github.sha }}
docker push $REG/$APP_NAME:latest
docker build -t $REG/${{ github.repository_owner }}/$APP_NAME:${{ github.sha }} -t $REG/${{ github.repository_owner }}/$APP_NAME:latest .
docker push $REG/${{ github.repository_owner }}/$APP_NAME:${{ github.sha }}
docker push $REG/${{ github.repository_owner }}/$APP_NAME:latest
#───────────────── deploy ─────────────────
deploy:
@@ -33,6 +33,7 @@ jobs:
runs-on: docker
env:
REG: ${{ vars.REGISTRY_URL }}
REPO_OWNER: ${{ github.repository_owner }}
APP_NAME: ${{ vars.APP_NAME }}
# Variables de entorno para docker-compose
APP_DOMAIN: ${{ vars.APP_DOMAIN }}
@@ -46,7 +47,7 @@ jobs:
run: |
echo " Deploying ${{ vars.APP_NAME }}"
echo " Domain: ${{ vars.APP_DOMAIN }}"
echo " Registry: ${{ vars.REGISTRY_URL }}"
echo " Image: ${{ vars.REGISTRY_URL }}/${{ github.repository_owner }}/${{ vars.APP_NAME }}:latest"
echo " Network: principal"
- name: Pull fresh images used in compose

View File

@@ -70,7 +70,9 @@ Para configurar el despliegue automático, ve a tu repositorio en Gitea:
- `REGISTRY_PASSWORD` - Contraseña del registro Docker
**Variables (valores públicos):**
- `REGISTRY_URL` - URL del registro Docker (ej: `registry.ejemplo.com`)
- `REGISTRY_URL` - URL del registro Docker (ej: `gitea.nucleoriofrio.com`)
- El owner del repositorio se agrega automáticamente
- Imagen final: `REGISTRY_URL/owner/APP_NAME:latest`
- `APP_NAME` - Nombre de la aplicación (ej: `mi-app`) - usado para container, imagen y Traefik
- `APP_DOMAIN` - Dominio de la aplicación (ej: `miapp.ejemplo.com`)
- `NUXT_PUBLIC_APP_URL` - URL pública de la app (ej: `https://miapp.ejemplo.com`)

View File

@@ -2,7 +2,7 @@ version: '3.8'
services:
app:
image: ${REG}/${APP_NAME}:latest
image: ${REG}/${REPO_OWNER}/${APP_NAME}:latest
container_name: ${APP_NAME}
restart: unless-stopped
environment: