Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +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
Expand Down Expand Up @@ -108,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
3 changes: 0 additions & 3 deletions api/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ type Config struct {

GithubTokens []string

RateLimitRPS int

CacheTTL time.Duration

RequestTimeout time.Duration
Expand Down Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions api/internal/infrastructure/github/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion api/internal/infrastructure/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Loading