commit d32c6c483b04e602105cdf63c6d1d6f127c906d0 Author: Sebastiaan de Schaetzen Date: Thu Nov 13 12:42:50 2025 +0100 Initial commit diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..285e2b8 --- /dev/null +++ b/action.yml @@ -0,0 +1,5 @@ +name: 'Watchtower Update' +description: 'Automatically triggers Watchtower to scan for new images' +runs: + using: 'go' + main: 'main.go' diff --git a/main.go b/main.go new file mode 100644 index 0000000..9bd6a1d --- /dev/null +++ b/main.go @@ -0,0 +1,39 @@ +package main + +import ( + "fmt" + "io" + "net/http" + "os" +) + +func main() { + token := "mytoken" + + url := "https://watchtower.seeseepuff.be/v1/update" + req, err := http.NewRequest("GET", url, nil) + if err != nil { + fmt.Fprintf(os.Stderr, "Failed to create request: %v\n", err) + os.Exit(1) + } + req.Header.Set("Authorization", "Bearer "+token) + + fmt.Printf("Triggering Watchtower update...") + resp, err := http.DefaultClient.Do(req) + if err != nil { + fmt.Fprintf(os.Stderr, "HTTP request failed: %v\n", err) + os.Exit(1) + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + fmt.Fprintf(os.Stderr, "HTTP request failed: %s\n", resp.Status) + os.Exit(1) + } + + if _, err := io.Copy(os.Stdout, resp.Body); err != nil { + fmt.Fprintf(os.Stderr, "Failed to read response: %v\n", err) + os.Exit(1) + } + fmt.Printf("Done!") +}