From 40c187a162f7d651f33b0352f8f7a63beba1b74b Mon Sep 17 00:00:00 2001 From: uno/hurtki Date: Thu, 26 Mar 2026 20:37:06 +0200 Subject: [PATCH 1/2] add: git pull in CI deploy job + cleanup: config --- .github/workflows/deploy.yaml | 2 ++ api/internal/config/config.go | 3 --- api/internal/infrastructure/github/fetcher.go | 1 + api/internal/infrastructure/server/server.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index e92d298..56200f9 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -73,6 +73,8 @@ jobs: port: ${{ secrets.SSH_PORT }} script: | cd ~/deploy/github-banners/ + git checkout master + git pull VER=$VERSION docker compose -f docker-compose.prod.yaml pull VER=$VERSION docker compose -f docker-compose.prod.yaml up -d --build health-check: diff --git a/api/internal/config/config.go b/api/internal/config/config.go index 3363987..5513921 100644 --- a/api/internal/config/config.go +++ b/api/internal/config/config.go @@ -13,8 +13,6 @@ type Config struct { GithubTokens []string - RateLimitRPS int - CacheTTL time.Duration RequestTimeout time.Duration @@ -45,7 +43,6 @@ func Load() *Config { Port: getEnv("PORT", "80"), CORSOrigins: corsOrigins, GithubTokens: githubTokens, - RateLimitRPS: getEnvAsInt("RATE_LIMIT_RPS", 10), CacheTTL: getEnvAsDuration("CACHE_TTL", 5*time.Minute), RequestTimeout: getEnvAsDuration("REQUEST_TIMEOUT", 10*time.Second), LogLevel: getEnv("LOG_LEVEL", "info"), diff --git a/api/internal/infrastructure/github/fetcher.go b/api/internal/infrastructure/github/fetcher.go index 298ae9a..20dcadf 100644 --- a/api/internal/infrastructure/github/fetcher.go +++ b/api/internal/infrastructure/github/fetcher.go @@ -203,6 +203,7 @@ func (f *Fetcher) FetchUserData(ctx context.Context, username string) (*domain.G return &domain.GithubUserData{ Username: user.GetLogin(), + Bio: user.Bio, Name: user.Name, Company: user.Company, Location: user.Location, diff --git a/api/internal/infrastructure/server/server.go b/api/internal/infrastructure/server/server.go index 17718da..eea0e9c 100644 --- a/api/internal/infrastructure/server/server.go +++ b/api/internal/infrastructure/server/server.go @@ -29,7 +29,7 @@ func New(cfg *config.Config, handler http.Handler, logger log.Logger) *Server { Addr: fmt.Sprintf(":%s", cfg.Port), Handler: handler, ReadTimeout: 10 * time.Second, - WriteTimeout: 30 * time.Second, + WriteTimeout: cfg.RequestTimeout, IdleTimeout: 60 * time.Second, }, logger: logger.With("service", "http-server"), From c737eb86f2d22deb266f315efb9a7f1f9ef04d21 Mon Sep 17 00:00:00 2001 From: uno/hurtki Date: Thu, 26 Mar 2026 20:53:08 +0200 Subject: [PATCH 2/2] add: better rollback with db dump + sleep in deploy --- .github/workflows/deploy.yaml | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 56200f9..2786a43 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -72,11 +72,22 @@ jobs: key: ${{ secrets.SSH_KEY }} port: ${{ secrets.SSH_PORT }} script: | - cd ~/deploy/github-banners/ + cd ~/deploy/github-banners/api + export $(cat .env | grep -v '^#' | xargs) + cd .. + + mkdir -p ~/backups/ + + PREV_TAG=$(git tag --sort=-creatordate | sed -n '2p' | sed 's/^v//') + + docker exec -t postgres pg_dump -U $POSTGRES_USER $POSTGRES_DB > ~/backups/backup_$PREV_TAG.sql + git checkout master git pull VER=$VERSION docker compose -f docker-compose.prod.yaml pull VER=$VERSION docker compose -f docker-compose.prod.yaml up -d --build + + sleep 5 health-check: runs-on: ubuntu-latest needs: deploy @@ -110,6 +121,19 @@ jobs: key: ${{ secrets.SSH_KEY }} port: ${{ secrets.SSH_PORT }} script: | - cd ~/deploy/github-banners/ + cd ~/deploy/github-banners/api + export $(cat .env | grep -v '^#' | xargs) + cd .. + + git fetch --tags + git checkout v$PREV_VERSION + docker compose -f docker-compose.prod.yaml stop api renderer storage nginx kafka + + + docker exec -i postgres psql -U $POSTGRES_USER -c "DROP DATABASE $POSTGRES_DB;" + docker exec -i postgres psql -U $POSTGRES_USER -c "CREATE DATABASE $POSTGRES_DB;" + docker exec -i postgres psql -U $POSTGRES_USER $POSTGRES_DB < ~/backups/backup_$PREV_VERSION.sql + + VER=$PREV_VERSION docker compose -f docker-compose.prod.yaml pull VER=$PREV_VERSION docker compose -f docker-compose.prod.yaml up -d --build