Le checkout en CI
Les environnements CI font checkout de votre code à neuf à chaque job.
Clone shallow pour la vitesse
git clone --depth=1 https://example.com/repo.git
- uses: actions/checkout@v4
with:
fetch-depth: 1
git fetch --unshallow
Sparse checkout pour monorepos
git sparse-checkout init --cone
git sparse-checkout set apps/web shared/ui
Cacher .git entre jobs
cache:
key: git-$CI_COMMIT_REF_SLUG
paths:
- .git/
Clonage authentifié
git clone https://oauth2:${TOKEN}@gitlab.com/group/repo.git
Builds reproductibles
npm ci
cargo build --locked
Détecter les fichiers changés
BASE=$(git merge-base origin/main HEAD)
CHANGED=$(git diff --name-only $BASE)
if echo "$CHANGED" | grep -q '^apps/web/'; then
./scripts/test-web.sh
fi
Workflows pilotés par tag
Secrets hors de Git
- uses: gitleaks/gitleaks-action@v2
Tagger le build
SHA=$(git rev-parse --short HEAD)
docker build -t myapp:$SHA -t myapp:latest .