mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-26 11:52:43 +03:00
48 lines
1.1 KiB
Bash
Executable File
48 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# push [INTERVALSECS] - push to github CI branch, watch for a successful run, then push to master
|
|
|
|
set -e
|
|
|
|
INTERVAL="${1:-10}"
|
|
|
|
LOCALBRANCH=master
|
|
REMOTECIBRANCH=simon
|
|
REMOTEMAINBRANCH=master
|
|
NUMRUNS=3
|
|
NUMCOMMITS=5
|
|
CISTARTDELAY=5 # between ci push and run start
|
|
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
|
|
}
|
|
|
|
ciwait() {
|
|
runlog
|
|
echo "waiting for CI to start..."
|
|
sleep $CISTARTDELAY
|
|
runlog
|
|
echo "waiting for CI to finish..."
|
|
ciwatch "$INTERVAL"
|
|
runlog
|
|
echo "waiting for master to notice CI success..."
|
|
sleep $MAINPUSHDELAY
|
|
}
|
|
|
|
echo "latest local commits are:"
|
|
gitlog
|
|
echo "force-pushing $LOCALBRANCH to github/$REMOTECIBRANCH"
|
|
git push -f github $LOCALBRANCH:$REMOTECIBRANCH
|
|
ciwait
|
|
echo "pushing CI-passing $LOCALBRANCH to $REMOTEMAINBRANCH"
|
|
git push github $LOCALBRANCH:$REMOTEMAINBRANCH
|
|
echo "latest commits on github/$REMOTEMAINBRANCH are:"
|
|
gitlog github/$REMOTEMAINBRANCH
|
|
echo "done"
|