Some checks failed
CI / commitlint (pull_request) Has been cancelled
CI / lint (pull_request) Has been cancelled
CI / test (pull_request) Has been cancelled
CI / build (pull_request) Has been cancelled
CI / commitlint (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
CI / build (push) Has been cancelled
CI/CD Gitea starter
Empty on purpose: only CI/CD, Docker, compose, and instructions so you can drop your app in.
Structure
.gitea/workflows/ci.yml: lint -> test -> build with auto-versioning, git tags, Docker imageslatest+vX.Y.Z..gitea/workflows/deploy.yml: manual Deploy (workflow_dispatch) to staging or prod.docker-compose.staging.yml/docker-compose.prod.yml: per-environment compose.Dockerfile: skeleton image to replace with your app build./opt/mon-projet/env/{staging,prod}/.env: generated on the VPS from Gitea secrets..commitlintrc.yml: commit linting rules (conventional-style) enforced in CI.scripts/commit-msg.sh: local commit-msg hook helper (commitlint via npx, no Docker).
Required Gitea secrets
DOCKER_REGISTRY: registry (e.g. registry.example.com).DOCKER_IMAGE: image name (e.g. mon-projet).DOCKER_USERNAME/DOCKER_PASSWORD: registry credentials.GITEA_TOKEN: token with push rights on the repo (for git tag push).STAGING_ENV_VARS: full.envcontent for staging (multi-line allowed).PROD_ENV_VARS: full.envcontent for prod.
CI workflow (ci.yml)
- Triggers:
pushandpull_request. - Strict order:
commitlint->lint->test->build. Any failure stops later jobs. - Auto-versioning rules (conventional commits):
feat:=> MINOR,fix:=> PATCH,feat!orBREAKING CHANGE=> MAJOR.- Tag created (
vX.Y.Z) + changelog artifact on pushes tomain.
- Builds and pushes Docker images
latestandvX.Y.Zto the configured registry.
Deploy workflow (deploy.yml)
- Trigger: manual only (
workflow_dispatch) with inputenv(staging|prod) and optionalversion(to force a prod tag). - Jobs:
prepare->build->deploy-*(staging or prod). Deployments always depend on the build. - Build: rebuilds and pushes both tags (
latest+vX.Y.Z) before any deploy. .envgeneration: secretsSTAGING_ENV_VARS/PROD_ENV_VARSare written on the VPS to/opt/mon-projet/env/<env>/.env.- Docker deploy:
docker compose pullthendocker compose up -dwith the dedicated compose files. - Prod uses the explicit version tag; staging consumes
latest.
Local commitlint (optional)
- Requires Node.js + npm locally (no Docker).
- One-time setup:
npm install --save-dev @commitlint/cli - Install the hook:
cp scripts/commit-msg.sh .git/hooks/commit-msg && chmod +x .git/hooks/commit-msg - The hook will block commits whose messages are not conventional-style (
feat,fix,chore, etc.). - Windows (Git Bash) : chmod est optionnel ; copie simplement le fichier dans
.git/hooks/commit-msg. Vérifie quenpxfonctionne (npx --version).
Pour un débutant : comment ça marche ?
- Commits propres : écris tes messages comme
feat: ...(nouvelle fonctionnalité) oufix: ...(correction). Ça pilote l’auto-versioning. - Pousser le code : un
git pushou une PR lance la CI (vérifie les commits, le lint, les tests, construit l’image Docker). - Versions automatiques : sur la branche
main, la CI calcule la prochaine versionvX.Y.Z, tague le repo et pousse les images Docker (latestetvX.Y.Z). - Déploiements : rien d’automatique. Tu lances manuellement le workflow Deploy dans l’onglet Actions de Gitea :
- Choisis
stagingpour déployer l’imagelatest. - Choisis
prodpour déployer l’imagevX.Y.Z(dernier tag ou celui que tu fournis dans l’inputversion).
- Choisis
- Secrets : tes mots de passe/variables sensibles restent dans l’UI Gitea (pas dans le code). Ils servent à créer les fichiers
.envsur le serveur et à pousser les images. - Serveur : le runner doit avoir Docker/compose et pouvoir écrire dans
/opt/mon-projet/. Les.envsont générés à chaque déploiement et ne sont jamais commités.
How to use
- Update
Dockerfile, lint/test commands inci.yml, and services/ports/volumes in compose files to match your app. - Add the secrets above in the Gitea repo settings.
- Push code with commit messages
feat:,fix:, orfeat!/BREAKING CHANGEto drive semver bumps. - Make sure CI is green. No automatic deployment will run if CI fails (and deploy stays manual).
- Run the Deploy workflow in Gitea Actions:
env=staging: deploys imagelatest.env=prod: deploys image taggedvX.Y.Z(latest tag by default or the one supplied viaversion).
Notes
- Runner must access
/opt/mon-projet/and Docker/compose. .envfiles are never versioned; they are regenerated on each deploy from secrets.- If no tag exists yet, provide
versionmanually for a prod deploy.
Description
Languages
Shell
79.9%
Dockerfile
20.1%