intelligent check for new tags before building
This commit is contained in:
24
.drone.yml
24
.drone.yml
@@ -4,14 +4,23 @@ type: docker
|
||||
name: default
|
||||
|
||||
steps:
|
||||
# Step 1: Install dependencies & build Node.js app
|
||||
- name: install-and-build
|
||||
image: node:20-alpine
|
||||
# Step 1: Check if Docker image for current version already exists
|
||||
- name: check-version
|
||||
image: docker:24
|
||||
environment:
|
||||
DOCKER_HOST: unix:///var/run/docker.sock
|
||||
commands:
|
||||
- echo "Installing dependencies..."
|
||||
- npm ci
|
||||
- echo "Building app..."
|
||||
- npm run build
|
||||
- apk add --no-cache git
|
||||
- git fetch --tags
|
||||
- LATEST_TAG=$(git describe --tags --abbrev=0)
|
||||
- echo "Latest Git tag: $LATEST_TAG"
|
||||
- |
|
||||
if docker image inspect apps/homepage:$NEW_VERSION > /dev/null 2>&1; then
|
||||
echo "Docker image apps/homepage:$NEW_VERSION already exists — skipping build"
|
||||
exit 0
|
||||
else
|
||||
echo "Docker image apps/homepage:$NEW_VERSION not found — building..."
|
||||
fi
|
||||
|
||||
# Step 2: Build Docker image with dynamic Git tag
|
||||
- name: build-image
|
||||
@@ -50,4 +59,5 @@ steps:
|
||||
# Trigger pipeline on Git tags
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
- tag
|
||||
|
Reference in New Issue
Block a user