forked from freudenreichan/EinfuehrungInDocker_Pipeline2
Some checks failed
continuous-integration/drone/push Build is failing
65 lines
1.9 KiB
YAML
65 lines
1.9 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:
|
|
# Hier definieren wir die Variable für diesen Step
|
|
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"
|
|
|
|
# REPARATUR: Wir nutzen das Token direkt in der URL.
|
|
# WICHTIG: Das doppelte $$ ist für Drone zwingend erforderlich!
|
|
- git clone https://niegratschkato95684:$${GITEA_TOKEN}@git.efi.th-nuernberg.de/gitea/niegratschkato95684/EinfuehrungInDocker_Pipeline2.git
|
|
- cd EinfuehrungInDocker_Pipeline2
|
|
|
|
# Branch wechseln oder erstellen
|
|
- git checkout drone-artifacts || git checkout -b drone-artifacts
|
|
|
|
# Artifact löschen (falls vorhanden)
|
|
- git rm image.tar || echo "image.tar not found, skipping rm"
|
|
|
|
# Neue Datei kopieren und hinzufügen
|
|
- cp $DRONE_WORKSPACE/image.tar .
|
|
- git add image.tar
|
|
|
|
# Commit
|
|
- git commit -m "Add built Docker image [skip ci]" || echo "Nothing to commit"
|
|
|
|
# Push mit dem Token in der Remote-URL (wurde durch den Clone oben schon gesetzt)
|
|
- git push origin drone-artifacts |