hledger/tools/push

49 lines
1.1 KiB
Plaintext
Raw Normal View History

2022-12-12 00:30:48 +03:00
#!/usr/bin/env bash
2022-12-12 04:31:40 +03:00
# push [INTERVALSECS] - push to github CI branch, watch for a successful run, then push to master
2022-12-12 00:30:48 +03:00
set -e
INTERVAL="${1:-10}"
LOCALBRANCH=master
2023-01-21 23:21:38 +03:00
REMOTE=github
2022-12-12 00:30:48 +03:00
REMOTECIBRANCH=simon
REMOTEMAINBRANCH=master
NUMRUNS=3
NUMCOMMITS=5
2022-12-12 04:31:40 +03:00
CISTARTDELAY=5 # between ci push and run start
2022-12-12 00:52:01 +03:00
MAINPUSHDELAY=5 # between run end and master push
gitlog() {
REF=$1
git log --format='%ad %h %s%d' --date=short -$NUMCOMMITS ${REF:+"$REF"}
}
runlog() {
echo "latest runs are:"
gh run list -L$NUMRUNS
}
2022-12-12 00:30:48 +03:00
ciwait() {
2022-12-12 00:52:01 +03:00
runlog
2022-12-12 00:30:48 +03:00
echo "waiting for CI to start..."
sleep $CISTARTDELAY
2022-12-12 00:52:01 +03:00
runlog
2022-12-12 00:30:48 +03:00
echo "waiting for CI to finish..."
ciwatch "$INTERVAL"
2022-12-12 00:52:01 +03:00
runlog
echo "waiting for master to notice CI success..."
sleep $MAINPUSHDELAY
2022-12-12 00:30:48 +03:00
}
2022-12-12 00:52:01 +03:00
echo "latest local commits are:"
gitlog
2023-01-21 23:21:38 +03:00
echo "force-pushing $LOCALBRANCH to $REMOTE/$REMOTECIBRANCH"
git push -f $REMOTE $LOCALBRANCH:$REMOTECIBRANCH
2022-12-12 00:30:48 +03:00
ciwait
2023-01-21 23:21:38 +03:00
echo "pushing CI-passing $LOCALBRANCH to $REMOTE/$REMOTEMAINBRANCH"
git push $REMOTE $LOCALBRANCH:$REMOTEMAINBRANCH
echo "latest commits on $REMOTE/$REMOTEMAINBRANCH are:"
gitlog $REMOTE/$REMOTEMAINBRANCH
2022-12-12 00:30:48 +03:00
echo "done"