mirror of https://github.com/captn3m0/outliner.git
Adds git-sync support
This commit is contained in:
parent
cf2ac7eebc
commit
156bc86457
|
@ -4,6 +4,9 @@ WORKDIR /outliner
|
||||||
COPY . /outliner/
|
COPY . /outliner/
|
||||||
|
|
||||||
RUN gem install bundler && \
|
RUN gem install bundler && \
|
||||||
bundle install
|
bundle install && \
|
||||||
|
apk add --no-cache git && \
|
||||||
|
echo -e "StrictHostKeyChecking no" >> /etc/ssh/ssh_config && \
|
||||||
|
mkdir /root/.ssh
|
||||||
|
|
||||||
ENTRYPOINT ["/outliner/entrypoint.sh"]
|
ENTRYPOINT ["/outliner/entrypoint.sh"]
|
||||||
|
|
|
@ -5,15 +5,50 @@ if [ $# -eq 0 ]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
setup_git() {
|
||||||
|
chmod 0400 /root/.ssh/id_rsa
|
||||||
|
|
||||||
|
if [ -f "$HOME.ssh/id_rsa" ]; then
|
||||||
|
chmod 600 "$HOME.ssh/id_rsa"
|
||||||
|
|
||||||
|
if [ ! -d "$HOME.ssh/id_rsa.pub" ]; then
|
||||||
|
ssh-keygen -y -f "$HOME.ssh/id_rsa" > "$HOME.ssh/id_rsa.pub"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[+] Using SSH key for git pushes"
|
||||||
|
else
|
||||||
|
echo "[E] Git credentials not available, quitting"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
update_git_repo() {
|
||||||
|
BRANCH=${GIT_BRANCH:-master}
|
||||||
|
# Clone the branch in a temporary directory
|
||||||
|
tmp_dir=$(mktemp -d)
|
||||||
|
git clone "$GIT_REMOTE_URL" "$tmp_dir"
|
||||||
|
cp -r "$1/*" "$tmp_dir/"
|
||||||
|
cd "$tmp_dir" || exit 1
|
||||||
|
git add .
|
||||||
|
git commit -m "Updates: $(date)"
|
||||||
|
git push origin "$BRANCH"
|
||||||
|
}
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
export)
|
export)
|
||||||
shift
|
shift
|
||||||
bundle exec outliner-export $@
|
bundle exec outliner-export "$@"
|
||||||
|
|
||||||
|
if [ -z "$GIT_REMOTE_URL" ]; then
|
||||||
|
echo "GIT_REMOTE_URL not set"
|
||||||
|
else
|
||||||
|
setup_git
|
||||||
|
update_git_repo "$2"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
import)
|
import)
|
||||||
shift
|
shift
|
||||||
bundle exec outliner-import $@
|
bundle exec outliner-import "$@"
|
||||||
break
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Invalid command, please check README"
|
echo "Invalid command, please check README"
|
||||||
|
|
Loading…
Reference in New Issue