Compare commits

...

2 commits

Author SHA1 Message Date
Cat /dev/Nulo 360233de40 usar url dinamica en index.html 2023-01-22 22:04:25 -03:00
Cat /dev/Nulo 832a4a9fc3 permitir definir public_url 2023-01-22 22:02:59 -03:00
3 changed files with 10 additions and 3 deletions

View file

@ -4,7 +4,9 @@
<script>
const el = document.querySelector("pre");
const id = location.hash.slice(1);
const ws = new WebSocket("ws://localhost:8080/logs/socket/" + id);
const ws = new WebSocket(
location.origin.replace(/^http/, "ws") + "/logs/socket/" + id
);
window.ws = ws;
ws.addEventListener("message", async (event) => {
el.append(await event.data.text());

View file

@ -36,6 +36,7 @@ type config struct {
giteaUrl string
giteaUsername string
giteaPassword string
publicUrl string
}
func parseConfig() (c config) {
@ -59,5 +60,10 @@ func parseConfig() (c config) {
log.Fatal("GITEA_PASSWORD is nil")
}
if c.publicUrl = os.Getenv("PUBLIC_URL"); len(c.publicUrl) == 0 {
log.Println("PUBLIC_URL is not defined, will default to localhost:8080")
c.publicUrl = "http://localhost:8080"
}
return
}

View file

@ -140,8 +140,7 @@ func (h webhook) ServeHTTP(w http.ResponseWriter, req *http.Request) {
}
runId := req.Header.Get("X-Gitea-Delivery")
// TODO: make dynamic
runUrl := "http://localhost:8080/#" + runId
runUrl := h.config.publicUrl + "/#" + runId
log.Printf("New run: %s", runUrl)
run := runss.newRun(runId)
defer run.finishRun()