init

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