[git] Finishes push command

This commit is contained in:
Nemo 2019-08-14 15:09:11 +05:30
parent 09287e7612
commit d68dd6e79e
3 changed files with 27 additions and 4 deletions

View File

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## 0.2.1 - 2019-08-14
- Adds a `push` command (See #2)
## 0.2.0 - 2019-08-12
- Adds export command (See [#1013](https://github.com/outline/outline/pull/1013) for corresponding Outline PR)

View File

@ -81,10 +81,27 @@ docker run --env OUTLINE_BASE_URI="https://kb.example.com" \
import "/data" "Archive"
```
### Push
Note: Push is currently only available as a Docker Command
```bash
docker run --env OUTLINE_BASE_URI="https://kb.example.com" \
--env OUTLINE_TOKEN="PUT YOUR TOKEN HERE" \
--env OUTLINE_TOKEN="PUT YOUR TOKEN HERE" \
--env GIT_BRANCH=outline \
--env GIT_REMOTE_URL=git@example.com:org/outline.backup.git
--volume /etc/ssh/private.key:/root/.ssh/id_rsa
captn3m0/outliner \
push
```
#### Limitations
- Images are currently not imported. Host them externally for this to work.
- Only `.md` files are currently supported
- `push` doesn't sync file-history, but is meant to push a one-time backup to Git.
- `StrictHostKeyChecking` is currently disabled for `push`, please only run this in trusted networks.
## Development

View File

@ -1,13 +1,14 @@
#!/bin/sh
set -eu
if [ $# -eq 0 ]; then
echo "Please run with outliner [export|import] arguments"
echo "Please run with outliner [export|import|sync] arguments"
exit
fi
setup_git() {
if [ -f "$HOME/.ssh/id_rsa" ]; then
# This is required because Kubernetes secret mounts can't
# have file permissions set
chmod 0400 "$HOME/.ssh/id_rsa"
if [ ! -d "$HOME/.ssh/id_rsa.pub" ]; then
@ -51,10 +52,11 @@ case $1 in
git init
update_git_config
git add .
git commit --message "Backup: $(date)"
git commit --message "Backup: $(date)" > /dev/null
BRANCH=${GIT_BRANCH:-master}
git checkout -b "$BRANCH"
git push origin --force "$BRANCH"
git status
git push origin --force "HEAD:$BRANCH"
fi
;;
*)