Skip to content

Commit

Permalink
try workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
thedmdim committed May 15, 2024
1 parent e2d54e3 commit db5a784
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build-tele.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ jobs:

- name: SSH into the server and update the code
run: |
ssh $SERVER_USERNAME@$SERVER_IP "wget -qO - https://raw.githubusercontent.com/thedmdim/ytstalker/master/docker-compose.yml > /root/ytstalker/docker-compose.yml && docker compose -f /root/ytstalker/docker-compose.yml up --pull always -d tele"
ssh $SERVER_USERNAME@$SERVER_IP \
"wget -qO - https://raw.githubusercontent.com/thedmdim/ytstalker/master/docker-compose.yml > /root/ytstalker/docker-compose.yml
&& docker compose -f /root/ytstalker/docker-compose.yml up --pull always -d tele"
env:
SERVER_USERNAME: ${{ secrets.SERVER_USERNAME }}
SERVER_IP: ${{ secrets.SERVER_IP }}
5 changes: 4 additions & 1 deletion .github/workflows/build-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ jobs:

- name: SSH into the server and update the code
run: |
ssh $SERVER_USERNAME@$SERVER_IP "wget -qO - https://raw.githubusercontent.com/thedmdim/ytstalker/master/docker-compose.yml > /root/ytstalker/docker-compose.yml && docker compose -f /root/ytstalker/docker-compose.yml up --pull always -d app caddy"
ssh $SERVER_USERNAME@$SERVER_IP \
"wget -qO - https://raw.githubusercontent.com/thedmdim/ytstalker/master/docker-compose.yml > /root/ytstalker/docker-compose.yml
&& wget -qO - https://raw.githubusercontent.com/thedmdim/ytstalker/master/Caddyfile > /root/ytstalker/Caddyfile
&& docker compose -f /root/ytstalker/docker-compose.yml up --pull always -d app caddy"
env:
SERVER_USERNAME: ${{ secrets.SERVER_USERNAME }}
SERVER_IP: ${{ secrets.SERVER_IP }}
18 changes: 10 additions & 8 deletions cmd/app/handlers/rating_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
)

type Rating struct {
Best []*RatedVideo
Best []*RatedVideo
Worst []*RatedVideo
}

type RatedVideo struct {
ID string
Title string
ID string
Title string
Reactions int64
}

Expand All @@ -39,7 +39,7 @@ func (s *Router) GetRating(w http.ResponseWriter, r *http.Request) {
return
}

templates.ExecuteTemplate(w, "rating.html", rating)
Templates.ExecuteTemplate(w, "rating.html", rating)

}

Expand Down Expand Up @@ -71,13 +71,15 @@ func GetTopRated(conn *sqlite.Conn, coolRated bool, limit int64) ([]*RatedVideo,

if row {
ratedVideo := &RatedVideo{
ID: stmt.GetText("video_id"),
Title: stmt.GetText("title"),
ID: stmt.GetText("video_id"),
Title: stmt.GetText("title"),
Reactions: stmt.GetInt64("reactions_sum"),
}
result = append(result, ratedVideo)

} else { break }
} else {
break
}
}

if err := stmt.Reset(); err != nil {
Expand All @@ -88,4 +90,4 @@ func GetTopRated(conn *sqlite.Conn, coolRated bool, limit int64) ([]*RatedVideo,
}

return result, nil
}
}
6 changes: 3 additions & 3 deletions cmd/app/handlers/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
"zombiezen.com/go/sqlite/sqlitex"
)

var templates = template.Must(template.ParseGlob("web/*/*.html"))
var Templates *template.Template

type Router struct {
mux.Router
db *sqlitex.Pool
db *sqlitex.Pool
}

func NewRouter(db *sqlitex.Pool) *Router {
Expand All @@ -34,7 +34,7 @@ func NewRouter(db *sqlitex.Pool) *Router {
router.PathPrefix("/rating").Methods("GET").HandlerFunc(router.GetRating)
router.PathPrefix("/").Methods("GET").HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
err := templates.ExecuteTemplate(w, "random.html", nil)
err := Templates.ExecuteTemplate(w, "random.html", nil)
if err != nil {
log.Println(err.Error())
}
Expand Down
3 changes: 3 additions & 0 deletions cmd/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"fmt"
"html/template"
"log"
"net/http"
"os"
Expand All @@ -18,6 +19,8 @@ import (
)

func main() {
handlers.Templates = template.Must(template.ParseGlob("web/*/*.html"))

// prepare db
dsn := os.Getenv("DSN")
if dsn == "" {
Expand Down
1 change: 0 additions & 1 deletion cmd/tele/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ func GetKeyboard(year int) echotron.InlineKeyboardMarkup {
firstRow = append(firstRow, echotron.InlineKeyboardButton{Text: "<-", CallbackData: "/set" + strconv.Itoa(year-1)})
}


firstRow = append(firstRow, echotron.InlineKeyboardButton{Text: strconv.Itoa(year), CallbackData: "/noaction" + strconv.Itoa(year)})

if year >= time.Now().Year() {
Expand Down

0 comments on commit db5a784

Please sign in to comment.