init

AuthorKonata <konata@posteo.jp>
Date
Commitfa7c9b08f8ee4b5fcd21dbd4e636c6b9f5079cfc
6 files changed, 47 insertions(+)
▾A.env
@@ -0,0 +1,3 @@
PUSH_KEY=
PUSH_DELAY=
PUSH_URL=
▾ADockerfile
@@ -0,0 +1,11 @@
FROM alpine:edge
WORKDIR /opt
COPY autopush.sh .
RUN apk add git tini openssh
#should contain a key pair
#name of the key is is passed in via the SSH_KEY_NAME env variable, e.g. "id_rsa"
VOLUME /ssh
#should contain the repository to be pushed
VOLUME /git
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["/opt/autopush.sh"]
▾ATODO.md
@@ -0,0 +1,2 @@
* allow custom refspecs to be added (for e.g. git-bug)
* allow multiple repositories
▾Aautopush.sh
@@ -0,0 +1,27 @@
#!/bin/sh
set -e
if [ -z "$PUSH_KEY" ]; then
echo "Please set PUSH_KEY in .env"
exit 1
fi
if [ -z "$PUSH_DELAY" ]; then
echo "Please set PUSH_DELAY in .env to a string compatible with sleep(1)"
exit 1
fi
if [ -z "$PUSH_URL" ]; then
echo "Please set PUSH_DELAY in .env to a string compatible with sleep(1)"
exit 1
fi
cd /git
git rev-parse --git-dir || (echo "No repository detected at /git" && exit 1)
#use global config to not modify the repository
git config --global core.sshCommand "/usr/bin/ssh -o 'StrictHostKeyChecking no' -i /ssh/$PUSH_KEY"
while true; do
#using --mirror causes errors when pushing, but --prune,--force, plus these refspecs should catch most stuff
git push --force --prune "$PUSH_URL" '+refs/heads/*:refs/heads/*' '+refs/tags/*:refs/tags/*' '+refs/change/*:refs/change/*' || true
sleep "$PUSH_DELAY"
done
▾Agit/.gitignore
@@ -0,0 +1,2 @@
*
!.gitignore
▾Assh/.gitignore
@@ -0,0 +1,2 @@
*
!.gitignore