pipeline build v14 - GPT version of pipeline

This commit is contained in:
Josh 2025-07-31 14:51:45 +00:00
parent 9849137be1
commit 11a9afbddd

View File

@ -1,30 +1,37 @@
steps: steps:
push-to-staging: ssh-test: # name unchanged
image: google/cloud-sdk:latest image: google/cloud-sdk:latest
commands: commands:
- | - |
#!/bin/bash #!/usr/bin/env bash
set -eu set -euo pipefail
mkdir -p ~/.ssh mkdir -p ~/.ssh
# Inject known hosts # ── Fetch & install secrets from Secret Manager ─────────────
gcloud secrets versions access latest --secret=STAGING_KNOWN_HOSTS --project=aptivaai-dev | base64 -d > ~/.ssh/known_hosts 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
# Inject SSH key gcloud secrets versions access latest \
gcloud secrets versions access latest --secret=STAGING_SSH_KEY --project=aptivaai-dev | base64 -d > ~/.ssh/id_ed25519 --secret=STAGING_SSH_KEY --project=aptivaai-dev | base64 -d > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519 chmod 600 ~/.ssh/id_ed25519
# Confirm working tree location echo "🔑 SSH material ready"
SRC_DIR="$PWD/repo" # Assuming you cloned to ./repo
DEST_DIR="/home/jcoakley/dev1" # Confirm if this is correct on staging
# Clone dev1 repo # ── Tag comes from the commit that triggered Woodpecker ─────
git config --global user.name "Woodpecker CI" TAG=$(echo "$CI_COMMIT_SHA" | head -c 8)
git config --global user.email "ci@aptivaai.com" echo "🚀 Deploying tag ${TAG} to staging"
git clone https://jcoakley:f4bf7ac91bdbd16bf47d241860198ba0bbe4b5c6@gitea.dev1.aptivaai.com/jcoakley/dev1.git repo
# Rsync to staging VM # ── SSH into the staging VM and recreate the stack ─────────
rsync -az --delete -e "ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=yes" \ ssh -o StrictHostKeyChecking=yes \
--exclude '.git' \ -i ~/.ssh/id_ed25519 \
"$SRC_DIR/" jcoakley@10.128.0.12:"$DEST_DIR" jcoakley@10.128.0.12 <<EOF
set -euo pipefail
cd /opt/aptiva-staging-app
echo "Pulling containers with IMG_TAG=${TAG}"
IMG_TAG=${TAG} docker compose pull
echo "Recreating services"
IMG_TAG=${TAG} docker compose up -d --force-recreate --remove-orphans
echo "✅ Staging stack refreshed"
EOF