feat(ops/besadii): Run 'git update-server-info' at startup
Since besadii is effectively the entire post-receive hook, it also needs to do the entire job of the hook.
This commit is contained in:
parent
8377fd48f5
commit
21b76cb023
1 changed files with 13 additions and 1 deletions
|
@ -17,9 +17,12 @@ import (
|
||||||
"log/syslog"
|
"log/syslog"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var gitBin = "git"
|
||||||
|
|
||||||
// Represents an updated reference as passed to besadii by git
|
// Represents an updated reference as passed to besadii by git
|
||||||
//
|
//
|
||||||
// https://git-scm.com/docs/githooks#pre-receive
|
// https://git-scm.com/docs/githooks#pre-receive
|
||||||
|
@ -106,7 +109,7 @@ func triggerBuild(log *syslog.Writer, token, branch, commit string) {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
req.Header.Add("Authorization", "token " + token)
|
req.Header.Add("Authorization", "token "+token)
|
||||||
req.Header.Add("Content-Type", "application/json")
|
req.Header.Add("Content-Type", "application/json")
|
||||||
|
|
||||||
resp, err := http.DefaultClient.Do(req)
|
resp, err := http.DefaultClient.Do(req)
|
||||||
|
@ -159,6 +162,15 @@ func main() {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Before triggering builds, it is important that git
|
||||||
|
// update-server-info is run so that cgit correctly serves the
|
||||||
|
// repository.
|
||||||
|
err := exec.Command(gitBin, "update-server-info").Run()
|
||||||
|
if err != nil {
|
||||||
|
log.Alert("failed to run 'git update-server-info' for depot!")
|
||||||
|
os.Exit()
|
||||||
|
}
|
||||||
|
|
||||||
token, err := ioutil.ReadFile("/etc/secrets/srht-token")
|
token, err := ioutil.ReadFile("/etc/secrets/srht-token")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Alert("sourcehot token could not be read")
|
log.Alert("sourcehot token could not be read")
|
||||||
|
|
Loading…
Reference in a new issue