Fix authenticated artifact push
This commit is contained in:
parent
e9e0925d42
commit
10eba3b2b5
27
.drone.yml
27
.drone.yml
@ -20,6 +20,7 @@ steps:
|
|||||||
SIZE=$(stat -c%s image.tar)
|
SIZE=$(stat -c%s image.tar)
|
||||||
SIZE_MB=$((SIZE / 1024 / 1024))
|
SIZE_MB=$((SIZE / 1024 / 1024))
|
||||||
echo "Image size: ${SIZE_MB}MB"
|
echo "Image size: ${SIZE_MB}MB"
|
||||||
|
|
||||||
if [ "$SIZE_MB" -gt 150 ]; then
|
if [ "$SIZE_MB" -gt 150 ]; then
|
||||||
echo "Image too large!"
|
echo "Image too large!"
|
||||||
exit 1
|
exit 1
|
||||||
@ -32,9 +33,11 @@ steps:
|
|||||||
|
|
||||||
- name: push-artifact
|
- name: push-artifact
|
||||||
image: alpine:latest
|
image: alpine:latest
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
GITEA_TOKEN:
|
GITEA_TOKEN:
|
||||||
from_secret: GITEA_TOKEN
|
from_secret: GITEA_TOKEN
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
- apk add --no-cache git
|
- apk add --no-cache git
|
||||||
|
|
||||||
@ -42,26 +45,28 @@ steps:
|
|||||||
- git config --global user.email "drone@ci.local"
|
- git config --global user.email "drone@ci.local"
|
||||||
- git config --global user.name "Drone CI"
|
- git config --global user.name "Drone CI"
|
||||||
|
|
||||||
# Remote setzen
|
# Eigenes Repository mit Token clonen
|
||||||
#- git remote set-url origin https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2
|
- git clone https://oauth2:$GITEA_TOKEN@git.efi.th-nuernberg.de/gitea/spiesol91009/EinfuehrungInDocker_Pipeline2_OS.git
|
||||||
|
|
||||||
# Repo clonen
|
# In Repository wechseln
|
||||||
- git clone https://git.efi.th-nuernberg.de/gitea/freudenreichan/EinfuehrungInDocker_Pipeline2.git
|
- cd EinfuehrungInDocker_Pipeline2_OS
|
||||||
- cd EinfuehrungInDocker_Pipeline2
|
|
||||||
|
|
||||||
# Branch wechseln oder erstellen
|
# Branch wechseln oder erstellen
|
||||||
- git checkout drone-artifacts || git checkout -b drone-artifacts
|
- git checkout drone-artifacts || git checkout -b drone-artifacts
|
||||||
|
|
||||||
# Artifact löschen und neu hinzufügen
|
# Vorhandenes Artifact entfernen (falls vorhanden)
|
||||||
- git rm image.tar || true
|
- git rm image.tar || true
|
||||||
|
|
||||||
|
# Neues Artifact kopieren
|
||||||
- cp $DRONE_WORKSPACE/image.tar .
|
- cp $DRONE_WORKSPACE/image.tar .
|
||||||
|
|
||||||
|
# Datei hinzufügen
|
||||||
- git add image.tar
|
- git add image.tar
|
||||||
|
|
||||||
# Commit nur wenn Änderungen vorhanden
|
# Commit nur bei Änderungen
|
||||||
- git commit -m "Add built Docker image [skip ci]" || echo "Nothing to commit"
|
- git commit -m "Add built Docker image [skip ci]" || echo "Nothing to commit"
|
||||||
|
|
||||||
# Pull vor Push (um Konflikte zu vermeiden)
|
# Branch pushen
|
||||||
- git pull || true
|
|
||||||
|
|
||||||
# Push
|
|
||||||
- git push --set-upstream origin drone-artifacts
|
- git push --set-upstream origin drone-artifacts
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user