Compatible change (inputs unchanged); drop insecure-registry wording. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
48 lines
1.8 KiB
YAML
48 lines
1.8 KiB
YAML
name: gitops-bump
|
|
description: >
|
|
Points the app's kustomize overlay in the gitops repo at the image tag
|
|
just pushed (short sha of the triggering commit); ArgoCD picks up the
|
|
commit and deploys. Run on the `host` runner label (git + kustomize
|
|
installed there).
|
|
inputs:
|
|
app-name:
|
|
description: App name (dir under manifests/ and kustomize image name)
|
|
required: true
|
|
gitops-repo:
|
|
description: owner/name of the gitops repo
|
|
required: false
|
|
default: nholtware/gitops
|
|
gitops-token:
|
|
description: Token with write access to the gitops repo (pass secrets.GITOPS_TOKEN)
|
|
required: true
|
|
registry:
|
|
description: Registry host:port (must match build-push)
|
|
required: false
|
|
default: "git.lab.holtlabs.xyz"
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- shell: bash
|
|
env:
|
|
GITOPS_TOKEN: ${{ inputs.gitops-token }}
|
|
run: |
|
|
set -euo pipefail
|
|
TAG="${GITHUB_SHA:0:8}"
|
|
IMAGE="${{ inputs.registry }}/$GITHUB_REPOSITORY_OWNER/${{ inputs.app-name }}"
|
|
DIR="$(mktemp -d)"
|
|
trap 'rm -rf "$DIR"' EXIT
|
|
git clone --depth 1 "https://ci-bot:${GITOPS_TOKEN}@git.lab.holtlabs.xyz/${{ inputs.gitops-repo }}.git" "$DIR"
|
|
cd "$DIR/manifests/${{ inputs.app-name }}"
|
|
kustomize edit set image "${{ inputs.app-name }}=$IMAGE:$TAG"
|
|
cd "$DIR"
|
|
git -c user.name=ci-bot -c user.email=ci-bot@forgejo.local \
|
|
commit -am "${{ inputs.app-name }}: deploy $TAG" || { echo "tag unchanged, nothing to deploy"; exit 0; }
|
|
# Another app's deploy may push first: rebase (touches a different dir) and retry.
|
|
for i in 1 2 3 4 5; do
|
|
git push && exit 0
|
|
echo "push rejected (attempt $i), rebasing"
|
|
sleep $((i * 2))
|
|
git pull --rebase
|
|
done
|
|
echo "gitops push failed after 5 attempts" >&2
|
|
exit 1
|