Compare commits

..

1 Commits

Author SHA1 Message Date
1f883c4c04 chore: remove stray file 2026-03-03 12:58:00 -06:00
2 changed files with 22 additions and 70 deletions

View File

@@ -338,43 +338,41 @@ steps:
- security-trivy-orchestrator - security-trivy-orchestrator
- security-trivy-web - security-trivy-web
# ─── Deploy to Docker Swarm via Portainer API (main only) ───────────────────── # ─── Deploy to Docker Swarm (main only) ─────────────────────
# ─── Deploy to Docker Swarm via Portainer (main only) ─────────────────────
deploy-swarm: deploy-swarm:
image: alpine:3 image: alpine:3
environment: environment:
SSH_PRIVATE_KEY:
from_secret: ssh_private_key
SSH_KNOWN_HOSTS:
from_secret: ssh_known_hosts
PORTAINER_URL: PORTAINER_URL:
from_secret: portainer_url from_secret: portainer_url
PORTAINER_API_KEY: PORTAINER_API_KEY:
from_secret: portainer_api_key from_secret: portainer_api_key
PORTAINER_STACK_ID: "121"
commands: commands:
- apk add --no-cache curl - apk add --no-cache curl openssh-client
- | - |
set -e set -e
echo "🚀 Deploying to Docker Swarm via Portainer API..." echo "🚀 Deploying to Docker Swarm..."
# Use Portainer API to update the stack (forces pull of new images) # Setup SSH for fallback
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \ mkdir -p ~/.ssh
-H "X-API-Key: $PORTAINER_API_KEY" \ echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
-H "Content-Type: application/json" \ chmod 600 ~/.ssh/known_hosts
"$PORTAINER_URL/api/stacks/$PORTAINER_STACK_ID/git/redeploy") echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
HTTP_CODE=$(echo "$RESPONSE" | tail -1) # Force service updates (images are pulled from public registry)
BODY=$(echo "$RESPONSE" | head -n -1) ssh -o StrictHostKeyChecking=no localadmin@10.1.1.45 \
"docker service update --with-registry-auth --force mosaic-stack-api && \
if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "202" ]; then docker service update --with-registry-auth --force mosaic-stack-web && \
echo "✅ Stack update triggered successfully" docker service update --with-registry-auth --force mosaic-stack-orchestrator && \
else docker service update --with-registry-auth --force mosaic-stack-coordinator && \
echo "❌ Stack update failed (HTTP $HTTP_CODE)" echo '✅ All services updated'"
echo "$BODY"
exit 1
fi
# Wait for services to converge
echo "⏳ Waiting for services to converge..."
sleep 30
echo "✅ Deploy complete"
when: when:
- branch: [main] - branch: [main]
event: [push, manual, tag] event: [push, manual, tag]

View File

@@ -1,46 +0,0 @@
# Add this at the end of the file, replacing the deploy-swarm section
deploy-swarm:
image: alpine:3
environment:
SSH_PRIVATE_KEY:
from_secret: ssh_private_key
SSH_KNOWN_HOSTS:
from_secret: ssh_known_hosts
PORTAINER_URL:
from_secret: portainer_url
PORTAINER_API_KEY:
from_secret: portainer_api_key
commands:
- apk add --no-cache curl
- |
set -e
echo "🚀 Deploying via Portainer API..."
# Redeploy mosaic-stack (ID 121)
curl -sk -X POST \
-H "X-API-Key: $PORTAINER_API_KEY" \
"$PORTAINER_URL/api/stacks/121/git/redeploy" \
-H "Content-Type: application/json" \
-d '{"prune": false}' || \
# Fallback: Force service updates via SSH
echo "Trying SSH fallback..."
apk add --no-cache openssh-client
mkdir -p ~/.ssh
echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
chmod 600 ~/.ssh/known_hosts
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh -o StrictHostKeyChecking=no localadmin@10.1.1.45 \
"docker service update --force mosaic_api && \
docker service update --force mosaic_web && \
docker service update --force mosaic_orchestrator && \
docker service update --force mosaic_coordinator && \
echo '✅ Services updated'"
when:
- branch: [main]
event: [push, manual, tag]
depends_on:
- link-packages