seperate build and deploy
This commit is contained in:
@@ -97,32 +97,3 @@ while true; do
|
||||
sleep 5
|
||||
done
|
||||
|
||||
# Update k8s manifests
|
||||
echo "=== Updating manifests ==="
|
||||
K8S_DIR=$(mktemp -d)
|
||||
git clone --depth=1 "https://${GIT_USERNAME}:${GITEA_TOKEN}@gitea.saltysoup.dev/tanner/k8s.git" "${K8S_DIR}"
|
||||
sed -i "s|gitea.saltysoup.dev/tanner/${IMAGE}:.*|gitea.saltysoup.dev/tanner/${IMAGE}:${GITHUB_SHA}|g" \
|
||||
"${K8S_DIR}/apps/${APP_DIR}/deployment.yaml"
|
||||
git -C "${K8S_DIR}" config user.email "ci@saltysoup.dev"
|
||||
git -C "${K8S_DIR}" config user.name "CI Bot"
|
||||
git -C "${K8S_DIR}" add "apps/${APP_DIR}/deployment.yaml"
|
||||
if git -C "${K8S_DIR}" diff --staged --quiet; then
|
||||
echo "Manifest already at ${GITHUB_SHA}, skipping commit"
|
||||
else
|
||||
git -C "${K8S_DIR}" commit -m "ci: ${IMAGE} → ${GITHUB_SHA:0:8}"
|
||||
git -C "${K8S_DIR}" push
|
||||
fi
|
||||
rm -rf "${K8S_DIR}"
|
||||
|
||||
# Trigger ArgoCD refresh immediately
|
||||
echo "=== Triggering deploy ==="
|
||||
kubectl annotate application ${APP_DIR} -n argocd argocd.argoproj.io/refresh=normal --overwrite
|
||||
|
||||
# Wait for ArgoCD to apply the new image SHA to the deployment spec
|
||||
until kubectl get deployment ${APP_DIR} -n hungry -o jsonpath='{.spec.template.spec.containers[0].image}' 2>/dev/null | grep -q "${GITHUB_SHA}"; do
|
||||
sleep 3
|
||||
done
|
||||
|
||||
# Watch the rollout to completion
|
||||
echo "=== Watching rollout ==="
|
||||
kubectl rollout status deployment/${APP_DIR} -n hungry --timeout=5m
|
||||
@@ -0,0 +1,19 @@
|
||||
name: Deploy
|
||||
description: Updates the k8s manifest with the new image SHA and waits for ArgoCD to roll it out
|
||||
inputs:
|
||||
repo:
|
||||
description: Gitea repository name (used to derive the image and app directory)
|
||||
required: true
|
||||
image:
|
||||
description: Image name in the registry (defaults to repo name)
|
||||
required: false
|
||||
default: ''
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Update manifest and deploy
|
||||
shell: sh
|
||||
env:
|
||||
REPO: ${{ inputs.repo }}
|
||||
IMAGE: ${{ inputs.image }}
|
||||
run: sh ${{ github.action_path }}/deploy.sh
|
||||
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
IMAGE=${IMAGE:-$REPO}
|
||||
APP_DIR=$(echo "${IMAGE}" | tr '_' '-')
|
||||
|
||||
# Update k8s manifests
|
||||
echo "=== Updating manifests ==="
|
||||
K8S_DIR=$(mktemp -d)
|
||||
git clone --depth=1 "https://${GIT_USERNAME}:${GITEA_TOKEN}@gitea.saltysoup.dev/tanner/k8s.git" "${K8S_DIR}"
|
||||
sed -i "s|gitea.saltysoup.dev/tanner/${IMAGE}:.*|gitea.saltysoup.dev/tanner/${IMAGE}:${GITHUB_SHA}|g" \
|
||||
"${K8S_DIR}/apps/${APP_DIR}/deployment.yaml"
|
||||
git -C "${K8S_DIR}" config user.email "ci@saltysoup.dev"
|
||||
git -C "${K8S_DIR}" config user.name "CI Bot"
|
||||
git -C "${K8S_DIR}" add "apps/${APP_DIR}/deployment.yaml"
|
||||
if git -C "${K8S_DIR}" diff --staged --quiet; then
|
||||
echo "Manifest already at ${GITHUB_SHA}, skipping commit"
|
||||
else
|
||||
git -C "${K8S_DIR}" commit -m "ci: ${IMAGE} → ${GITHUB_SHA:0:8}"
|
||||
git -C "${K8S_DIR}" push
|
||||
fi
|
||||
rm -rf "${K8S_DIR}"
|
||||
|
||||
# Trigger ArgoCD refresh immediately
|
||||
echo "=== Triggering deploy ==="
|
||||
kubectl annotate application ${APP_DIR} -n argocd argocd.argoproj.io/refresh=normal --overwrite
|
||||
|
||||
# Wait for ArgoCD to apply the new image SHA to the deployment spec
|
||||
until kubectl get deployment ${APP_DIR} -n hungry -o jsonpath='{.spec.template.spec.containers[0].image}' 2>/dev/null | grep -q "${GITHUB_SHA}"; do
|
||||
sleep 3
|
||||
done
|
||||
|
||||
# Watch the rollout to completion
|
||||
echo "=== Watching rollout ==="
|
||||
kubectl rollout status deployment/${APP_DIR} -n hungry --timeout=5m
|
||||
Reference in New Issue
Block a user