Sebastian Mark
1edbc436db
- Add new Kubernetes manifests for `renovate-bot` in `k8s-manifests/` directory
- The Kubernetes manifests include a ConfigMap for `renovate-bot` configuration and a CronJob definition
- The `renovate-bot` now runs as a Kubernetes CronJob scheduled daily
- Add new `start_renovate_bot.sh` script in `bin/` directory for manual job creation
- Update README and add new README.renovate
🤖
74 lines
1.8 KiB
Bash
Executable file
74 lines
1.8 KiB
Bash
Executable file
#! /bin/bash
|
|
|
|
## Author: Sebastian Mark
|
|
## CC-BY-SA (https://creativecommons.org/licenses/by-sa/4.0/deed.de)
|
|
## for civil use only
|
|
|
|
## start renovate cronjob manually
|
|
## Usage: start_renovate_bot.sh [--debug] [group/repo group/repo ...]
|
|
|
|
set -e
|
|
|
|
NS="renovate"
|
|
CRONJOBNAME="renovate-bot"
|
|
JOBNAME="renovate-bot-manual-$(openssl rand -hex 3)"
|
|
|
|
TMPFILE=$(mktemp)
|
|
|
|
## create a single job from cronjob
|
|
kubectl -n $NS --dry-run=client create job $JOBNAME --from=cronjob/$CRONJOBNAME -o yaml >$TMPFILE
|
|
|
|
## add debug env var
|
|
if [[ "$1" == "--debug" ]]; then
|
|
kubectl patch --local -f $TMPFILE --type='json' --patch='[
|
|
{
|
|
"op": "add",
|
|
"path": "/spec/template/spec/containers/0/env/-",
|
|
"value": { "name": "LOG_LEVEL", "value": "debug"}
|
|
}
|
|
]' -o yaml | sponge $TMPFILE
|
|
shift
|
|
fi
|
|
|
|
## limit job to passed repo(s)
|
|
if [[ $# -gt 0 ]]; then
|
|
## disable autodiscover
|
|
kubectl patch --local -f $TMPFILE --type='json' --patch='[
|
|
{
|
|
"op": "add",
|
|
"path": "/spec/template/spec/containers/0/args",
|
|
"value": ["--autodiscover=false"]
|
|
}
|
|
]' -o yaml | sponge $TMPFILE
|
|
|
|
## add each repo as single argument
|
|
for REPO in "$@"; do
|
|
kubectl patch --local -f $TMPFILE --type='json' --patch='[
|
|
{
|
|
"op": "add",
|
|
"path": "/spec/template/spec/containers/0/args/-",
|
|
"value": "'$REPO'"
|
|
}
|
|
]' -o yaml | sponge $TMPFILE
|
|
done
|
|
fi
|
|
|
|
## create job
|
|
kubectl -n $NS apply -f $TMPFILE
|
|
rm $TMPFILE
|
|
|
|
## wait for corrosponding pod to be ready
|
|
PODNAME=$(kubectl -n $NS get pods --selector=job-name=$JOBNAME --no-headers -o custom-columns=":metadata.name")
|
|
kubectl -n $NS wait --for=condition=Ready pod/$PODNAME --timeout=3m
|
|
|
|
## show job logs
|
|
echo "waiting for logs...."
|
|
echo
|
|
kubectl -n $NS logs -f job/$JOBNAME
|
|
echo
|
|
|
|
echo "saving log to /tmp/${JOBNAME}.log"
|
|
kubectl -n $NS logs job/$JOBNAME &>/tmp/${JOBNAME}.log
|
|
|
|
## remove job
|
|
kubectl -n $NS delete job $JOBNAME
|