54 lines
1.9 KiB
YAML
54 lines
1.9 KiB
YAML
# .gitea/workflows/build.yaml
|
|
name: Build and Push Docker Image
|
|
|
|
# Il workflow viene attivato su push
|
|
on:
|
|
push:
|
|
branches:
|
|
- 'main'
|
|
- 'master'
|
|
|
|
# Questa sezione è fondamentale per evitare build quando non necessario
|
|
# Gitea ignorerà automaticamente i commit che contengono queste stringhe [citation:10]
|
|
# Aggiungi "[skip ci]" al tuo messaggio di commit per saltare la build
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
# Questi due step preparano l'ambiente per build multi-architettura
|
|
- 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 Gitea Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
# IMPORTANTE: Sostituisci con il dominio del tuo Gitea (es. gitea.example.com)
|
|
registry: gitea.enrilinux.ovh
|
|
username: ${{ secrets.GITEA_USERNAME }}
|
|
password: ${{ secrets.GITEA_TOKEN }}
|
|
|
|
# Estrae il nome del repository e il tag (commit SHA) per l'immagine
|
|
- name: Extract metadata
|
|
id: meta
|
|
run: |
|
|
echo "REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F'/' '{print $2}')" >> $GITHUB_OUTPUT
|
|
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
# IMPORTANTE: Sostituisci "gitea.example.com" con il dominio del tuo Gitea
|
|
# e "username" con il tuo nome utente o organizzazione
|
|
tags: |
|
|
gitea.enrilinux.ovh/${{ github.repository_owner }}/${{ steps.meta.outputs.REPO_NAME }}:latest
|
|
gitea.enrilinux.ovh/${{ github.repository_owner }}/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.SHORT_SHA }}
|