working script
This commit is contained in:
parent
b0d0f53243
commit
69bcf40df5
@ -1,6 +1,9 @@
|
||||
FROM alpine:3.14
|
||||
RUN apk add --no-cache git openssh
|
||||
RUN mkdir -p /var/git-cloner/{repo,auth}
|
||||
RUN apk add --no-cache git
|
||||
RUN adduser -D git-cloner
|
||||
RUN mkdir -p /var/git-cloner/repo \
|
||||
&& chown -R git-cloner:git-cloner /var/git-cloner
|
||||
USER git-cloner
|
||||
WORKDIR /var/git-cloner
|
||||
COPY ./run.sh ./
|
||||
ENTRYPOINT ["sh", "-c", "/var/git-cloner/run.sh"]
|
||||
@ -2,8 +2,7 @@
|
||||
|
||||
# Environment
|
||||
- `INTERVAL`: interval to pull the repo, seconds
|
||||
- `URL`: git URL, in ssh format
|
||||
- `URL`: git URL
|
||||
|
||||
# Mounts
|
||||
- `/var/git-cloner/repo`: the cloned repo
|
||||
- `/var/git-cloner/auth`: directory containing ssh key
|
||||
|
||||
17
run.sh
17
run.sh
@ -1,20 +1,19 @@
|
||||
set -euxo pipefail
|
||||
|
||||
KEYFILE="$(find /var/git-cloner/auth -type f | grep -v 'pub$')"
|
||||
ls -alh "$KEYFILE"
|
||||
whoami
|
||||
export GIT_SSH_COMMAND="ssh -i $KEYFILE -o IdentitiesOnly=yes"
|
||||
|
||||
REPOPATH="/var/git-cloner/repo"
|
||||
|
||||
git config --global --add safe.directory "$REPOPATH"
|
||||
cd "$REPOPATH"
|
||||
|
||||
while true
|
||||
do
|
||||
if [ -d "repo/.git" ]; then
|
||||
# pull or clone
|
||||
if [ -d ".git" ]; then
|
||||
git pull
|
||||
else
|
||||
git clone "$URL" aa
|
||||
git clone "$URL" .
|
||||
fi
|
||||
sleep "$INTERVAL"
|
||||
|
||||
# allow sleep to be interrupted
|
||||
sleep "$INTERVAL" &
|
||||
wait $!
|
||||
done
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user