fixes
This commit is contained in:
parent
838438c67f
commit
d7a1276f1f
3 changed files with 9 additions and 6 deletions
|
@ -23,6 +23,7 @@ RUN printf '#!/bin/sh\n\n' > /entrypoint.sh && \
|
|||
printf 'git config --global --add safe.directory /data/alaskartv/docker-ci\n' >> /entrypoint.sh && \
|
||||
printf 'git config --global --add safe.directory /data/alaskartv/androidtv-ci\n\n' >> /entrypoint.sh && \
|
||||
# Finally, run the main app
|
||||
printf 'crond -b\n' >> /entrypoint.sh && \
|
||||
printf 'exec /app/api-server\n' >> /entrypoint.sh && \
|
||||
chmod +x /entrypoint.sh
|
||||
|
||||
|
|
12
main.go
12
main.go
|
@ -36,7 +36,8 @@ func updateVersion(repoPath string, serviceName string) error {
|
|||
"curl", "-X", "POST",
|
||||
fmt.Sprintf("https://api.telegram.org/bot%s/sendMessage", botToken),
|
||||
"-d", fmt.Sprintf("chat_id=%s", chatid),
|
||||
"-d", fmt.Sprintf("text=GO-SERVER: %s updated to %s", serviceName, newVersion),
|
||||
"-d", fmt.Sprintf("text=<b>Alaskar-api</b>: <b>%s</b> updated to <b>%s</b>", serviceName, newVersion),
|
||||
"-d", fmt.Sprintf("parse_mode=HTML"),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -92,7 +93,7 @@ func bumpVersionTv(repoPath string) {
|
|||
func notifyHandler(c *gin.Context) {
|
||||
var data struct {
|
||||
Name string `json:"name"`
|
||||
Image string `json:"image"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
if err := c.ShouldBindJSON(&data); err != nil {
|
||||
|
@ -103,20 +104,21 @@ func notifyHandler(c *gin.Context) {
|
|||
if data.Name == "" {
|
||||
data.Name = "unknown"
|
||||
}
|
||||
if data.Image == "" {
|
||||
data.Image = "unknown"
|
||||
if data.Message == "" {
|
||||
data.Message = "unknown"
|
||||
}
|
||||
|
||||
godotenv.Load(".botenv")
|
||||
botToken := os.Getenv("BOT_TOKEN")
|
||||
chatid := os.Getenv("CHAT_ID")
|
||||
|
||||
message := fmt.Sprintf("Service '%s' was updated to image '%s'", data.Name, data.Image)
|
||||
message := fmt.Sprintf("<b>Alaskar-api</b>: <b>%s</b> \n \n %s", data.Name, data.Message)
|
||||
|
||||
telegramAPI := fmt.Sprintf("https://api.telegram.org/bot%s/sendMessage", botToken)
|
||||
resp, err := http.PostForm(telegramAPI, url.Values{
|
||||
"chat_id": {chatid},
|
||||
"text": {message},
|
||||
"parse_mode": {"HTML"},
|
||||
})
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to send Telegram message"})
|
||||
|
|
|
@ -17,5 +17,5 @@ if [ "$latest_release" != "$version" ]; then
|
|||
curl -X POST "https://api.telegram.org/bot$BOT_TOKEN/sendMessage" \
|
||||
-d chat_id="$CHAT_ID" \
|
||||
-d text="🚀 New Release Detected: $latest_release on $REPO_OWNER/$REPO_NAME"
|
||||
curl -X POST "http://alaskar-api:8080/api/alaskartv"
|
||||
curl -X POST "http://api-server:9090/api/alaskartv"
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue