- build + push image dans le registry Gitea sur tag vX.Y.Z - création d'une release Gitea avec le compose de prod en asset - doc CI/CD dans le README Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
name: Release
|
||||
|
||||
# Livraison par tag : un tag "vX.Y.Z" déclenche build + push registry + release Gitea.
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
permissions:
|
||||
contents: write # créer la release
|
||||
packages: write # pousser dans le registry Gitea
|
||||
|
||||
env:
|
||||
REGISTRY: git.maisongrondin.fr
|
||||
# ⚠️ namespace du registry Gitea en minuscules
|
||||
IMAGE: git.maisongrondin.fr/alexandre/mkv2avi
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Version depuis le tag
|
||||
id: ver
|
||||
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Connexion au registry Gitea
|
||||
run: echo "${{ secrets.GITEA_TOKEN }}" | docker login "$REGISTRY" -u "${{ github.actor }}" --password-stdin
|
||||
|
||||
- name: Build & push de l'image
|
||||
run: |
|
||||
VERSION="${{ steps.ver.outputs.version }}"
|
||||
docker build -t "$IMAGE:$VERSION" -t "$IMAGE:latest" .
|
||||
docker push "$IMAGE:$VERSION"
|
||||
docker push "$IMAGE:latest"
|
||||
|
||||
- name: Release Gitea (+ compose de prod en asset)
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
|
||||
run: |
|
||||
VERSION="${{ steps.ver.outputs.version }}"
|
||||
TAG="${{ github.ref_name }}"
|
||||
BODY="Image Docker : \`$IMAGE:$VERSION\`\n\nDéploiement :\n\`docker compose --env-file .env.prod -f docker-compose.prod.yml up -d\`"
|
||||
REL_ID=$(curl -sSf -X POST "$API/releases" \
|
||||
-H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":\"$BODY\"}" | jq -r '.id')
|
||||
echo "Release créée (id=$REL_ID)"
|
||||
for f in docker-compose.prod.yml .env.prod.example; do
|
||||
curl -sSf -X POST "$API/releases/$REL_ID/assets?name=$f" \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-F "attachment=@$f;type=text/plain" >/dev/null
|
||||
echo " asset ajouté : $f"
|
||||
done
|
||||
@@ -149,6 +149,28 @@ proxy_send_timeout 3600s;
|
||||
Utilisable comme *Custom App* (Docker) : montez le dataset des films sur `/media`
|
||||
(en lecture seule) et un dataset de sortie sur `/output`, exposez le port `8000`.
|
||||
|
||||
## CI/CD (Gitea Actions)
|
||||
|
||||
Workflow `.gitea/workflows/release.yml` — **livraison par tag** :
|
||||
|
||||
```bash
|
||||
git tag v0.1.0
|
||||
git push origin v0.1.0
|
||||
```
|
||||
|
||||
À chaque tag `vX.Y.Z`, la pipeline :
|
||||
1. build l'image Docker ;
|
||||
2. la pousse dans le **registry Gitea** → `git.maisongrondin.fr/alexandre/mkv2avi:X.Y.Z` (+ `:latest`) ;
|
||||
3. crée une **release Gitea** avec `docker-compose.prod.yml` et `.env.prod.example` en pièces jointes.
|
||||
|
||||
L'authentification au registry utilise le **token automatique du runner** (`secrets.GITEA_TOKEN`),
|
||||
aucun secret à configurer. Pour cibler un autre registry (Distribution), changez `REGISTRY`/`IMAGE`
|
||||
en tête du workflow et ajoutez un `docker login` avec vos identifiants en secrets.
|
||||
|
||||
**Prérequis** : Actions activées sur le dépôt, un Act Runner avec accès Docker et le label
|
||||
`ubuntu-latest`. Le déploiement se fait ensuite manuellement (voir *Production* ci-dessus) :
|
||||
`docker compose --env-file .env.prod -f docker-compose.prod.yml up -d`.
|
||||
|
||||
## Variables d'environnement
|
||||
|
||||
| Variable | Défaut | Rôle |
|
||||
|
||||
Reference in New Issue
Block a user