kuebrichjo82295 f1c6307316
Some checks failed
continuous-integration/drone/push Build is failing
weitere aenderungen in .drone.yml ...
2026-04-24 09:33:12 +02:00

66 lines
2.1 KiB
YAML

kind: pipeline
type: docker
name: default
steps:
- name: build-image
image: gcr.io/kaniko-project/executor:debug
commands:
- /kaniko/executor
--context=.
--dockerfile=Dockerfile
--destination=test-app:latest
--no-push
--tar-path=image.tar
- name: size-check
image: alpine:latest
commands:
- |
SIZE=$(stat -c%s image.tar)
SIZE_MB=$((SIZE / 1024 / 1024))
echo "Image size: ${SIZE_MB}MB"
if [ "$SIZE_MB" -gt 150 ]; then
echo "Image too large!"
exit 1
fi
- name: security-scan
image: ghcr.io/aquasecurity/trivy:0.69.3
commands:
- trivy image --input image.tar --severity HIGH,CRITICAL --exit-code 1
- name: push-artifact
image: alpine:latest
environment:
# Das Secret muss in Drone unter diesem Namen angelegt sein!
GITEA_TOKEN:
from_secret: GITEA_TOKEN
commands:
- apk add --no-cache git
# Git Identität setzen
- git config --global user.email "drone@ci.local"
- git config --global user.name "Drone CI"
# Repo direkt mit Token clonen (oauth2 ist der Standard-User für Gitea-Tokens)
- git clone https://oauth2:$${GITEA_TOKEN}@git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2.git
- cd EinfuehrungInDocker_Pipeline2
# Branch wechseln oder lokal erstellen
- git checkout drone-artifacts || git checkout -b drone-artifacts
# Die Datei aus dem vorherigen Kaniko-Step in das Repo-Verzeichnis kopieren
- git rm --ignore-unmatch image.tar
- cp $DRONE_WORKSPACE/image.tar .
- git add image.tar
# Commit erstellen (falls sich nichts geändert hat, geht es dank || echo weiter)
- git commit -m "Add built Docker image [skip ci]" || echo "Nothing to commit"
# Pull versucht den Remote-Stand zu holen, falls der Branch auf Gitea schon existiert
- git pull origin drone-artifacts || true
# Jetzt klappt der Push, weil die URL oben das Token enthält
- git push --set-upstream origin drone-artifacts