mirror of https://github.com/captn3m0/outliner.git
[sync] Adds proper sync support
This commit is contained in:
parent
a264f8c2d9
commit
16e5ea504a
|
@ -9,3 +9,4 @@
|
|||
/vendor/
|
||||
Gemfile.lock
|
||||
*.gem
|
||||
.env
|
||||
|
|
|
@ -5,7 +5,7 @@ COPY . /outliner/
|
|||
|
||||
RUN gem install bundler && \
|
||||
bundle install && \
|
||||
apk add --no-cache git openssh-client && \
|
||||
apk add --no-cache git openssh-client rsync && \
|
||||
echo -e "StrictHostKeyChecking no" >> /etc/ssh/ssh_config && \
|
||||
mkdir /root/.ssh
|
||||
|
||||
|
|
4
LICENSE
4
LICENSE
|
@ -1,7 +1,7 @@
|
|||
Copyright 2019 Abhay Rana
|
||||
Copyright 2020 Abhay Rana
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
|
|
@ -41,22 +41,36 @@ case $1 in
|
|||
bundle exec outliner-import "$@"
|
||||
;;
|
||||
sync)
|
||||
tmp_dir=$(mktemp -d)
|
||||
BRANCH=${GIT_BRANCH:-master}
|
||||
old_git_dir=$(mktemp -d)
|
||||
fresh_export_dir=$(mktemp -d)
|
||||
if [ -z "$GIT_REMOTE_URL" ]; then
|
||||
echo "[E] GIT_REMOTE_URL not set"
|
||||
exit 1
|
||||
else
|
||||
git clone --branch "$BRANCH" "$GIT_REMOTE_URL" "$old_git_dir"
|
||||
setup_git
|
||||
bundle exec outliner-export "$tmp_dir"
|
||||
cd "$tmp_dir"
|
||||
git init
|
||||
update_git_config
|
||||
echo "[+] Exporting data from Outline"
|
||||
bundle exec outliner-export "$fresh_export_dir"
|
||||
echo "[+] Resetting git repository"
|
||||
cd "$old_git_dir"
|
||||
# We update so that git forgets all files
|
||||
git ls-files -z |xargs -n1 -0 git rm
|
||||
# Then we copy across the files from the new export
|
||||
cd "$fresh_export_dir"
|
||||
echo "[+] Updating git repository"
|
||||
rsync -av . "$old_git_dir"
|
||||
cd "$old_git_dir"
|
||||
echo "[+] Committing to git"
|
||||
git add .
|
||||
git commit --message "Backup: $(date)" > /dev/null
|
||||
BRANCH=${GIT_BRANCH:-master}
|
||||
git checkout -b "$BRANCH"
|
||||
git status
|
||||
git push origin --force "HEAD:$BRANCH"
|
||||
echo "[+] Pushing to git remote"
|
||||
git push origin "HEAD:$BRANCH"
|
||||
echo "[+] Cleaning up"
|
||||
rm -rf "$old_git_dir"
|
||||
rm -rf "$fresh_export_dir"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
OUTLINE_BASE_URI=https://outline.example.com
|
||||
GIT_BRANCH=master
|
||||
GIT_REMOTE_URL=git@example.com:org/outline.backup.git
|
||||
OUTLINE_TOKEN=
|
|
@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|||
spec.name = "outliner"
|
||||
spec.version = Outliner::VERSION
|
||||
spec.authors = ["Nemo"]
|
||||
spec.email = ["rubygem.outliner@captnemo.in"]
|
||||
spec.email = ["outliner@captnemo.in"]
|
||||
spec.licenses = ["MIT"]
|
||||
|
||||
spec.summary = "A simple HTTParty based client for outline knowledge base."
|
||||
|
|
Loading…
Reference in New Issue