Compare commits

...

3 Commits

Author SHA1 Message Date
3c31a0da83 Remove Go code 2025-11-13 13:07:21 +01:00
fc5fc66d5f Use a composite action
This is an attempt to see if this is faster than a Go action.
2025-11-13 13:06:32 +01:00
384201755f Add readme 2025-11-13 13:05:10 +01:00
3 changed files with 7 additions and 41 deletions

2
README.md Normal file
View File

@@ -0,0 +1,2 @@
# Watchtower Action
This action will automatically trigger an update of watchtower, causing containers that have the label `com.centurylinklabs.watchtower.enable=true` to be automatically updated.

View File

@@ -1,5 +1,8 @@
name: 'Watchtower Update' name: 'Watchtower Update'
description: 'Automatically triggers Watchtower to scan for new images' description: 'Automatically triggers Watchtower to scan for new images'
runs: runs:
using: 'go' using: 'composite'
main: 'main.go' steps:
- name: Trigger Watchtower Update
run: |
curl -H "Authorization: Bearer mytoken" https://watchtower.seeseepuff.be/v1/update

39
main.go
View File

@@ -1,39 +0,0 @@
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!")
}