Skip to content

Instantly share code, notes, and snippets.

@kphrx
Last active July 17, 2019 05:53
Show Gist options
  • Save kphrx/d6562136f6caf49227d711fb07f7c5bc to your computer and use it in GitHub Desktop.
Save kphrx/d6562136f6caf49227d711fb07f7c5bc to your computer and use it in GitHub Desktop.

update-pleroma

systemd timer unitで定期的に実行させる形 /opt/pleromaにpleromaをcloneしておく。その時upstreamを設定する

  1. dotenv.exmapledotenvにコピーして適宜変更
  2. update-pleroma.service/path/todotenvupdate-pleroma.shの置いてあるパスに向ける
  3. update-pleroma.serviceupdate-pleroma.timerをsystemdの管理下へ置いてsystemctl start update-pleroma.timerを実行
MAIN_BRANCH=pl.kpherox.dev
MIX_ENV=prod
HOME=/var/lib/pleroma
PLEROMA_PATH=/opt/pleroma
PLEROMA_USER=pleroma
[Unit]
Description=Pleroma auto update script
[Service]
Type=oneshot
EnvironmentFile=/path/to/dotenv
ExecStart=/usr/bin/sudo -Eu $PLEROMA_USER /path/to/update-pleroma.sh
ExecStartPost=/bin/systemctl restart pleroma.service
#!/bin/bash
cd "$PLEROMA_PATH"
git fetch --all
git checkout priv/static/static/js/app.*.js*
git stash save
git checkout $MAIN_BRANCH
git merge --ff-only origin/$MAIN_BRANCH
if [ $? -ne 0 ]; then
git merge --abort
git stash pop
exit 1
fi
git push origin --tags
git merge --no-ff -m "Merge branch 'develop' into $MAIN_BRANCH" upstream/develop
if [ $? -ne 0 ]; then
git merge --abort
git stash pop
exit 1
fi
git push
git stash pop
sed -i'' -e "s/\(\"\|'\)\(read write follow\)[\"']/\1\2 push\1/g" priv/static/static/js/app.*.js*
mix deps.get
if [ $? -ne 0 ]; then
exit 1
fi
mix compile
if [ $? -ne 0 ]; then
exit 1
fi
mix ecto.migrate
if [ $? -ne 0 ]; then
exit 1
fi
[Unit]
Description=Pleroma update daily
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment