pipeline build v41. correct reversion
This commit is contained in:
parent
f7847f8c38
commit
b8e967d949
@ -1,10 +1,10 @@
|
|||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: build-and-deploy
|
name: ssh-test
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
ssh-deploy:
|
- name: ssh-test
|
||||||
image: google/cloud-sdk:latest
|
image: google/cloud-sdk:latest
|
||||||
entrypoint:
|
entrypoint:
|
||||||
- bash
|
- bash
|
||||||
@ -14,34 +14,36 @@ steps:
|
|||||||
|
|
||||||
mkdir -p ~/.ssh;
|
mkdir -p ~/.ssh;
|
||||||
|
|
||||||
gcloud secrets versions access latest --secret=STAGING_KNOWN_HOSTS --project=aptivaai-dev | base64 -d > ~/.ssh/known_hosts;
|
# ── Inject known-hosts and SSH key ───────────────────────────────
|
||||||
|
gcloud secrets versions access latest \
|
||||||
|
--secret=STAGING_KNOWN_HOSTS --project=aptivaai-dev \
|
||||||
|
| base64 -d > ~/.ssh/known_hosts;
|
||||||
chmod 644 ~/.ssh/known_hosts;
|
chmod 644 ~/.ssh/known_hosts;
|
||||||
|
|
||||||
gcloud secrets versions access latest --secret=STAGING_SSH_KEY --project=aptivaai-dev | base64 -d > ~/.ssh/id_ed25519;
|
gcloud secrets versions access latest \
|
||||||
|
--secret=STAGING_SSH_KEY --project=aptivaai-dev \
|
||||||
|
| base64 -d > ~/.ssh/id_ed25519;
|
||||||
chmod 600 ~/.ssh/id_ed25519;
|
chmod 600 ~/.ssh/id_ed25519;
|
||||||
|
|
||||||
echo "🔑 SSH prerequisites installed";
|
echo "🔑 SSH prerequisites installed";
|
||||||
|
|
||||||
echo "📦 CI_COMMIT_SHA: ${CI_COMMIT_SHA:-unset}";
|
# ── SSH into staging and deploy ──────────────────────────────────
|
||||||
TAG="${CI_COMMIT_SHA:-}";
|
ssh -o StrictHostKeyChecking=yes \
|
||||||
if [ -z "$TAG" ]; then echo "❌ CI_COMMIT_SHA is blank. Aborting."; exit 1; fi;
|
-i ~/.ssh/id_ed25519 \
|
||||||
TAG=$(echo "$TAG" | head -c 8);
|
jcoakley@10.128.0.12 \
|
||||||
echo "🚀 Deploying tag ${TAG} to staging";
|
'set -euo pipefail; \
|
||||||
|
IMG_TAG=$(gcloud secrets versions access latest --secret=IMG_TAG --project=aptivaai-dev); \
|
||||||
ssh -o StrictHostKeyChecking=yes -i ~/.ssh/id_ed25519 jcoakley@10.128.0.12 \
|
export IMG_TAG; \
|
||||||
"export IMG_TAG=${TAG}; \
|
echo "📦 IMG_TAG=$IMG_TAG"; \
|
||||||
cd /home/jcoakley/aptiva-staging-app; \
|
cd /home/jcoakley/aptiva-staging-app; \
|
||||||
echo 'IMG_TAG = ${IMG_TAG}'; \
|
echo "IMG_TAG = $IMG_TAG"; \
|
||||||
echo '→ Pulling containers'; \
|
sudo --preserve-env=IMG_TAG docker compose pull; \
|
||||||
docker compose pull; \
|
sudo --preserve-env=IMG_TAG docker compose up -d --force-recreate --remove-orphans; \
|
||||||
echo '→ Recreating services'; \
|
echo "✅ Staging stack refreshed with tag $IMG_TAG"'
|
||||||
docker compose up -d --force-recreate --remove-orphans; \
|
|
||||||
echo '✅ Staging stack refreshed with tag ${IMG_TAG}'"
|
|
||||||
secrets:
|
secrets:
|
||||||
- STAGING_SSH_KEY
|
- STAGING_SSH_KEY
|
||||||
- STAGING_KNOWN_HOSTS
|
- STAGING_KNOWN_HOSTS
|
||||||
|
- IMG_TAG
|
||||||
environment:
|
|
||||||
CI_COMMIT_SHA: ${CI_COMMIT_SHA}
|
|
||||||
|
|
||||||
when:
|
when:
|
||||||
event:
|
event:
|
||||||
|
Loading…
Reference in New Issue
Block a user