pipeline build v24 - TAG slicing
This commit is contained in:
parent
c1117bf6be
commit
09dc756230
@ -9,7 +9,7 @@ steps:
|
|||||||
|
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
|
|
||||||
# ── Secrets for SSH ────────────────────────────────────────
|
# ── Inject known-hosts and SSH key from Secret Manager ─────
|
||||||
gcloud secrets versions access latest \
|
gcloud secrets versions access latest \
|
||||||
--secret=STAGING_KNOWN_HOSTS --project=aptivaai-dev \
|
--secret=STAGING_KNOWN_HOSTS --project=aptivaai-dev \
|
||||||
| base64 -d > ~/.ssh/known_hosts
|
| base64 -d > ~/.ssh/known_hosts
|
||||||
@ -22,36 +22,30 @@ steps:
|
|||||||
|
|
||||||
echo "🔑 SSH prerequisites installed"
|
echo "🔑 SSH prerequisites installed"
|
||||||
|
|
||||||
# ── Log what the CI knows ──────────────────────────────────
|
# ── Tag slicing from CI_COMMIT_SHA only ────────────────────
|
||||||
echo "🔍 CI_COMMIT_SHA: ${CI_COMMIT_SHA:-unset}"
|
TAG=$(echo "${CI_COMMIT_SHA}" | head -c 8)
|
||||||
echo "🔍 CI_COMMIT: ${CI_COMMIT:-unset}"
|
if [ -z "$TAG" ]; then
|
||||||
echo "🔍 DRONE_COMMIT_SHA: ${DRONE_COMMIT_SHA:-unset}"
|
echo "❌ CI_COMMIT_SHA is missing or blank"
|
||||||
|
|
||||||
# ── Resolve tag safely ─────────────────────────────────────
|
|
||||||
RAW_SHA="${CI_COMMIT_SHA:-${CI_COMMIT:-${DRONE_COMMIT_SHA:-}}}"
|
|
||||||
if [ -z "$RAW_SHA" ]; then
|
|
||||||
echo "❌ CI commit SHA not found. Aborting."
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
TAG=$(echo "$RAW_SHA" | head -c 8)
|
|
||||||
echo "🚀 Deploying tag ${TAG} to staging"
|
echo "🚀 Deploying tag ${TAG} to staging"
|
||||||
|
|
||||||
# ── SSH into staging and refresh ───────────────────────────
|
# ── SSH into staging and refresh the Docker stack ──────────
|
||||||
ssh -o StrictHostKeyChecking=yes \
|
ssh -o StrictHostKeyChecking=yes \
|
||||||
-i ~/.ssh/id_ed25519 \
|
-i ~/.ssh/id_ed25519 \
|
||||||
jcoakley@10.128.0.12 \
|
jcoakley@10.128.0.12 \
|
||||||
"export IMG_TAG=${TAG}; \
|
"export IMG_TAG=${TAG}; \
|
||||||
cd /home/jcoakley/aptiva-staging-app; \
|
cd /home/jcoakley/aptiva-staging-app; \
|
||||||
echo 'Pulling containers with IMG_TAG=${IMG_TAG}'; \
|
echo 'IMG_TAG = ${IMG_TAG}'; \
|
||||||
|
echo '→ Pulling containers'; \
|
||||||
docker compose pull; \
|
docker compose pull; \
|
||||||
echo 'Recreating services'; \
|
echo '→ Recreating services'; \
|
||||||
docker compose up -d --force-recreate --remove-orphans; \
|
docker compose up -d --force-recreate --remove-orphans; \
|
||||||
echo '✅ Staging stack refreshed with tag ${IMG_TAG}'"
|
echo '✅ Staging stack refreshed with tag ${IMG_TAG}'"
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
CI_COMMIT_SHA: ${CI_COMMIT_SHA}
|
CI_COMMIT_SHA: ${CI_COMMIT_SHA}
|
||||||
CI_COMMIT: ${CI_COMMIT}
|
|
||||||
DRONE_COMMIT_SHA: ${DRONE_COMMIT_SHA}
|
|
||||||
|
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
|
Loading…
Reference in New Issue
Block a user