This commit is contained in:
70
.drone.yml
70
.drone.yml
@@ -16,48 +16,6 @@ volumes:
|
|||||||
path: /var/run/docker.sock
|
path: /var/run/docker.sock
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# -----------------------------------------------------
|
|
||||||
# 1. Fetch latest Git tag
|
|
||||||
# -----------------------------------------------------
|
|
||||||
- name: fetch-tags
|
|
||||||
image: docker:24
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run/docker.sock
|
|
||||||
commands:
|
|
||||||
- apk add --no-cache git
|
|
||||||
- git fetch --tags
|
|
||||||
- |
|
|
||||||
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null | tr -d '\n')
|
|
||||||
echo "Latest Git tag: $LATEST_TAG"
|
|
||||||
echo "$LATEST_TAG" > /drone/src/LATEST_TAG.txt
|
|
||||||
if [ -z "$LATEST_TAG" ]; then
|
|
||||||
echo "❌ No git tags found. Cannot continue."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# -----------------------------------------------------
|
|
||||||
# 2. Check if remote image already exists
|
|
||||||
# -----------------------------------------------------
|
|
||||||
- name: check-remote-image
|
|
||||||
image: docker:24
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run/docker.sock
|
|
||||||
environment:
|
|
||||||
REGISTRY_HOST:
|
|
||||||
from_secret: REGISTRY_HOST
|
|
||||||
commands:
|
|
||||||
- IMAGE_TAG=$(cat /drone/src/LATEST_TAG.txt | tr -d '\n')
|
|
||||||
- echo "Checking if $REGISTRY_HOST/lila-games/nakama-server:$IMAGE_TAG exists..."
|
|
||||||
- |
|
|
||||||
if docker pull $REGISTRY_HOST/lila-games/nakama-server:$IMAGE_TAG > /dev/null 2>&1; then
|
|
||||||
echo "✅ Image already exists: $REGISTRY_HOST/lila-games/nakama-server:$IMAGE_TAG"
|
|
||||||
exit 78
|
|
||||||
else
|
|
||||||
echo "⚙️ Image does not exist. Will build."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
# 3. Build Nakama Docker image
|
# 3. Build Nakama Docker image
|
||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
@@ -82,32 +40,6 @@ steps:
|
|||||||
--push \
|
--push \
|
||||||
/drone/src
|
/drone/src
|
||||||
|
|
||||||
# -----------------------------------------------------
|
|
||||||
# 4. Push Nakama image to registry
|
|
||||||
# -----------------------------------------------------
|
|
||||||
- name: push-image
|
|
||||||
image: docker:24
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run/docker.sock
|
|
||||||
environment:
|
|
||||||
REGISTRY_HOST:
|
|
||||||
from_secret: REGISTRY_HOST
|
|
||||||
REGISTRY_USER:
|
|
||||||
from_secret: REGISTRY_USER
|
|
||||||
REGISTRY_PASS:
|
|
||||||
from_secret: REGISTRY_PASS
|
|
||||||
commands:
|
|
||||||
- IMAGE_TAG=$(cat /drone/src/LATEST_TAG.txt | tr -d '\n')
|
|
||||||
- echo "🔑 Logging into registry..."
|
|
||||||
- echo "$REGISTRY_PASS" | docker login $REGISTRY_HOST -u "$REGISTRY_USER" --password-stdin
|
|
||||||
- echo "🏷️ Tagging images..."
|
|
||||||
- docker tag lila-games/nakama-server:$IMAGE_TAG $REGISTRY_HOST/lila-games/nakama-server:$IMAGE_TAG
|
|
||||||
- docker tag lila-games/nakama-server:$IMAGE_TAG $REGISTRY_HOST/lila-games/nakama-server:latest
|
|
||||||
- echo "📤 Pushing images..."
|
|
||||||
- docker push $REGISTRY_HOST/lila-games/nakama-server:$IMAGE_TAG
|
|
||||||
- docker push $REGISTRY_HOST/lila-games/nakama-server:latest
|
|
||||||
|
|
||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
# 5. Stop old Nakama container
|
# 5. Stop old Nakama container
|
||||||
# -----------------------------------------------------
|
# -----------------------------------------------------
|
||||||
@@ -158,3 +90,5 @@ steps:
|
|||||||
trigger:
|
trigger:
|
||||||
event:
|
event:
|
||||||
- tag
|
- tag
|
||||||
|
- push
|
||||||
|
- custom
|
||||||
|
|||||||
Reference in New Issue
Block a user