Update .drone.yml
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Some checks reported errors
continuous-integration/drone/push Build encountered an error
split check version into 2 steps to tackle different environments for git and docker tag comparison
This commit is contained in:
26
.drone.yml
26
.drone.yml
@@ -12,23 +12,33 @@ workspace:
|
||||
path: /drone/src
|
||||
|
||||
steps:
|
||||
# Step 1: Check if image for the latest tag exists locally
|
||||
- name: check-version
|
||||
# Step 1a: Git fetch tags locally
|
||||
- name: fetch-tags
|
||||
image: docker:24
|
||||
environment:
|
||||
DOCKER_HOST: unix:///var/run/docker.sock
|
||||
DOCKER_HOST: unix:///var/run/docker.sock # local Docker, if needed
|
||||
commands:
|
||||
- apk add --no-cache git
|
||||
- git fetch --tags
|
||||
- |
|
||||
LATEST_TAG=$(git describe --tags --abbrev=0)
|
||||
echo "Latest Git tag: $LATEST_TAG"
|
||||
echo "Latest Git tag fetched: $LATEST_TAG"
|
||||
# Save to file to share with next step
|
||||
echo $LATEST_TAG > /drone/src/LATEST_TAG.txt
|
||||
|
||||
if docker image inspect apps/homepage:$LATEST_TAG > /dev/null 2>&1; then
|
||||
echo "✅ Docker image apps/homepage:$LATEST_TAG already exists — skipping build"
|
||||
exit 78 # tells Drone to stop pipeline gracefully
|
||||
# Step 1b: Check if image exists on remote LAN Docker
|
||||
- name: check-remote-image
|
||||
image: docker:24
|
||||
environment:
|
||||
DOCKER_HOST: tcp://192.168.1.111:2376 # remote Docker
|
||||
commands:
|
||||
- IMAGE_TAG=$(cat /drone/src/LATEST_TAG.txt)
|
||||
- echo "Checking if apps/homepage:$IMAGE_TAG exists on remote Docker..."
|
||||
- if docker image inspect apps/homepage:$IMAGE_TAG > /dev/null 2>&1; then
|
||||
echo "✅ Docker image apps/homepage:$IMAGE_TAG already exists — skipping build";
|
||||
exit 78; # stop pipeline gracefully
|
||||
else
|
||||
echo "⚙️ Docker image apps/homepage:$LATEST_TAG not found — proceeding to build..."
|
||||
echo "⚙️ Docker image apps/homepage:$IMAGE_TAG not found — proceeding to build...";
|
||||
fi
|
||||
|
||||
# Step 2: Build Docker image (dynamic tag)
|
||||
|
||||
Reference in New Issue
Block a user