1+ #
2+ # Variables for remote host
3+ # =========================
4+ VPS_USER ?= static_content_user
5+ VPS_HOST ?= static.europython.eu
6+ VPS_PROD_PATH ?= /home/static_content_user/content/europython_websites/ep2025test
7+ VPS_PREVIEW_PATH ?= /home/static_content_user/content/europython_websites/previews/
8+ REMOTE_CMD =ssh $(VPS_USER ) @$(VPS_HOST )
9+
10+ # Variables for build/deploy
11+ # ==========================
12+ export TIMESTAMP := $(shell date +% Y% m% d% H% M% S)
13+ export GIT_VERSION := $(shell git rev-parse --short HEAD)
14+
15+ # Variables for deploy
16+ # ====================
17+ # Auto-detect and sanitize current git branch
18+ BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
19+ # Replace "/" and other non-alphanumeric characters with "-"
20+ SAFE_BRANCH := $(shell echo "$(BRANCH ) " | sed 's/[^A-Za-z0-9._-]/-/g')
21+
22+ # TODO: update this to the prod branches
23+ ifeq ($(SAFE_BRANCH ) , deployment-simpler)
24+ RELEASES_DIR := $(VPS_PATH)/releases
25+ else
26+ RELEASES_DIR := $(VPS_PATH)/preview/$(SAFE_BRANCH)/releases
27+ endif
28+
29+ TARGET := $(RELEASES_DIR ) /$(TIMESTAMP )
30+
31+ .PHONY : build deploy dev clean install
32+
133pre :
2- python -m pip install pre-commit ansible
3- pre-commit install
434 npm install -g pnpm
535
636install :
@@ -9,17 +39,16 @@ install:
939dev :
1040 pnpm dev
1141
12- build :
13- pnpm build
14-
15- deploy :
16- $(if $(findstring Windows_NT, $(OS ) ) , \
17- $(error Deployment is not supported on Windows. Use WSL or a Unix-like system.) , \
18- @read -p " Enter SSH username: " USERNAME; \
19- read -p " Enter inline inventory (e.g., 'host1,' (DO NOT forget the trailing comma)): " INVENTORY; \
20- ansible-playbook -u $$ USERNAME -i " $$ INVENTORY" deploy.yml)
21-
2242clean :
2343 git clean -fdX
2444
25- .PHONY : pre install dev build deploy clean
45+ build :
46+ # TODO: update this to just `pnpm build` after resolving the astro-check warnings
47+ pnpm run astro build
48+
49+ deploy :
50+ @echo " \n\n**** Deploying branch '$( BRANCH) ' (safe: $( SAFE_BRANCH) ) to $( TARGET) ...\n\n"
51+ $(REMOTE_CMD ) " mkdir -p $( TARGET) "
52+ rsync -avz --delete ./dist/ $(VPS_USER ) @$(VPS_HOST ) :$(TARGET ) /
53+ $(REMOTE_CMD ) " cd $( RELEASES_DIR) && ln -snf $( TIMESTAMP) current"
54+ @echo " \n\n**** Deployment complete.\n\n"
0 commit comments