Compare commits
3 Commits
d32c6c483b
...
v1
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c31a0da83 | |||
| fc5fc66d5f | |||
| 384201755f |
2
README.md
Normal file
2
README.md
Normal 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.
|
||||
@@ -1,5 +1,8 @@
|
||||
name: 'Watchtower Update'
|
||||
description: 'Automatically triggers Watchtower to scan for new images'
|
||||
runs:
|
||||
using: 'go'
|
||||
main: 'main.go'
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Trigger Watchtower Update
|
||||
run: |
|
||||
curl -H "Authorization: Bearer mytoken" https://watchtower.seeseepuff.be/v1/update
|
||||
|
||||
39
main.go
39
main.go
@@ -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!")
|
||||
}
|
||||
Reference in New Issue
Block a user