Tobias Niegratschka 9db3d2b12e
Some checks reported errors
continuous-integration/drone/push Build encountered an error
continuous-integration/drone Build encountered an error
.drone.yml aktualisiert
2026-04-25 14:11:04 +00:00

66 lines
2.0 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:
GITEA_TOKEN:
from_secret: GITEA_TOKEN
commands:
- apk add --no-cache git
# Git konfigurieren
- git config --global user.email "drone@ci.local"
- git config --global user.name "Drone CI"
# 1. Klonen ohne Token (falls öffentlich lesbar) oder mit Token
# Wir nutzen hier eine stabilere Syntax für die Credentials
- git clone https://git.efi.th-nuernberg.de/gitea/niegratschkato95684/EinfuehrungInDocker_Pipeline2.git
- cd EinfuehrungInDocker_Pipeline2
# 2. Den Token für den Push in der URL hinterlegen
# Wir überschreiben die Origin-URL mit dem Token
- git remote set-url origin https://niegratschkato95684:$${GITEA_TOKEN}@git.efi.th-nuernberg.de/gitea/niegratschkato95684/EinfuehrungInDocker_Pipeline2.git
# 3. Branch-Logik
- git checkout drone-artifacts || git checkout -b drone-artifacts
# 4. Datei-Operationen
- git rm image.tar || echo "image.tar not found"
- cp $DRONE_WORKSPACE/image.tar .
- git add image.tar
# 5. Commit & Push
- git commit -m "Add built Docker image [skip ci]" || echo "Nothing to commit"
# Wir pushen explizit mit dem Token
- git push origin drone-artifacts