From faaa05795362cf89b26cc86a2f060ad7d3d85886 Mon Sep 17 00:00:00 2001 From: Anja Freudenreich Date: Sat, 11 Apr 2026 07:04:55 +0000 Subject: [PATCH] =?UTF-8?q?.drone.yml=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..bc02ddf --- /dev/null +++ b/.drone.yml @@ -0,0 +1,67 @@ +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: aquasec/trivy:latest + 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" + + # Remote setzen + #- git remote set-url origin https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline + + # Repo clonen + - git clone https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline.git + - cd EinfuehrungInDocker_Pipeline + + # Branch wechseln oder erstellen + - git checkout drone-artifacts || git checkout -b drone-artifacts + + # Artifact löschen und neu hinzufügen + - git rm image.tar + - cp $DRONE_WORKSPACE/image.tar . + - git add image.tar + + # Commit nur wenn Änderungen vorhanden + - git commit -m "Add built Docker image [skip ci]" || echo "Nothing to commit" + + # Pull vor Push (um Konflikte zu vermeiden) + - git pull || true + + # Push + - git push \ No newline at end of file