Skip to content

Commit 219ef3c

Browse files
committed
Restore production deploy infrastructure with static.europython.eu
Replace development server references in deploy configuration with the production static.europython.eu host and restore the releases/symlink deployment pattern. - Makefile: restore VPS variables, release/symlink deploy and preview targets, safe_branch helper; adapt to use build/ output directory - build-deploy.yml: fix deploy host, restore timestamp, use make ship - preview.yml: fix deploy host, restore timestamp, delegate to make preview and safe_branch targets
1 parent 2a06c89 commit 219ef3c

3 files changed

Lines changed: 72 additions & 13 deletions

File tree

.github/workflows/build-deploy.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ jobs:
1616
- name: Checkout repository
1717
uses: actions/checkout@v4
1818

19+
- name: Set timestamp for build/deploy
20+
run: echo "TIMESTAMP=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
21+
1922
- name: Set up uv
2023
uses: astral-sh/setup-uv@v5
2124

@@ -28,7 +31,7 @@ jobs:
2831
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
2932

3033
- name: ssh keyscan
31-
run: ssh-keyscan "ls.artcz.pl" > ~/.ssh/known_hosts
34+
run: ssh-keyscan "static.europython.eu" > ~/.ssh/known_hosts
3235

3336
- name: Download data
3437
env:
@@ -41,4 +44,4 @@ jobs:
4144
run: make download-avatars
4245

4346
- name: Build and deploy
44-
run: make ship
47+
run: make ship FORCE_DEPLOY=true

.github/workflows/preview.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ jobs:
1919
- name: Checkout
2020
uses: actions/checkout@v4
2121

22+
- name: Set timestamp for build/deploy
23+
run: echo "TIMESTAMP=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
24+
2225
- name: Set up uv
2326
uses: astral-sh/setup-uv@v5
2427

@@ -31,7 +34,7 @@ jobs:
3134
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
3235

3336
- name: ssh keyscan
34-
run: ssh-keyscan "ls.artcz.pl" > ~/.ssh/known_hosts
37+
run: ssh-keyscan "static.europython.eu" > ~/.ssh/known_hosts
3538

3639
- name: Download data
3740
env:
@@ -40,16 +43,17 @@ jobs:
4043
EP_SCHEDULE_API: ${{ vars.EP_SCHEDULE_API }}
4144
run: make download-data
4245

43-
- name: Build preview
46+
- name: Build and upload preview
4447
env:
48+
BRANCH: "${{ env.GITHUB_BRANCH_NAME }}"
4549
SITE_URL: "https://${{ env.GITHUB_BRANCH_NAME }}.${{ env.PREVIEW_HOSTNAME }}"
46-
run: make build-all
50+
run: make preview
4751

48-
- name: Deploy preview
52+
- name: Get safe branch and export to env
53+
env:
54+
BRANCH: ${{ env.GITHUB_BRANCH_NAME }}
4955
run: |
50-
SAFE_BRANCH=$(echo "${{ env.GITHUB_BRANCH_NAME }}" | tr '/' '-' | tr '[:upper:]' '[:lower:]')
51-
rsync -avz --delete build/ static_content_user@ls.artcz.pl:/home/static_content_user/content/preview/${SAFE_BRANCH}/
52-
echo "SAFE_BRANCH=${SAFE_BRANCH}" >> $GITHUB_ENV
56+
echo "SAFE_BRANCH=$(make safe_branch)" >> $GITHUB_ENV
5357
5458
- name: Update PR comment
5559
uses: actions/github-script@v7

Makefile

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,36 @@
1-
.PHONY: build build-all clean deploy ship serve server lint format type-check test test-cov download-data download-avatars watch dev
1+
.PHONY: build build-all clean deploy ship serve server lint format type-check test test-cov download-data download-avatars watch dev preview safe_branch
2+
3+
#
4+
# Variables for remote host
5+
# =========================
6+
VPS_USER ?= static_content_user
7+
VPS_HOST ?= static.europython.eu
8+
VPS_PROD_PATH ?= /home/static_content_user/content/europython_websites/ep2026
9+
VPS_PREVIEW_PATH ?= /home/static_content_user/content/previews
10+
REMOTE_CMD=ssh $(VPS_USER)@$(VPS_HOST)
11+
12+
#
13+
# Variables for build/deploy
14+
# ==========================
15+
export TIMESTAMP ?= $(shell date +%Y%m%d%H%M%S)
16+
17+
#
18+
# Variables for deploy
19+
# ====================
20+
BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
21+
SAFE_BRANCH := $(shell echo "$(BRANCH)" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g')
22+
FORCE_DEPLOY ?= false
23+
PREVIEW_SITE_URL ?= "https://$(SAFE_BRANCH).ep-preview.click"
224

325
ENV ?= development
426
-include .env.$(ENV)
527
export EP_SESSIONS_API EP_SPEAKERS_API EP_SCHEDULE_API EP_FAST_BUILD EP_MINIFY EP_AVATAR_PROXY SITE_URL
628

729
GIT_COMMIT := $(shell git rev-parse --short=8 HEAD 2>/dev/null)
830

31+
safe_branch:
32+
@echo $(SAFE_BRANCH)
33+
934
build:
1035
uv run src/build.py --commit $(GIT_COMMIT)
1136

@@ -40,7 +65,6 @@ download-data:
4065
download-avatars:
4166
uv run src/download_avatars.py
4267

43-
4468
watch:
4569
uvx watchfiles 'make build-all' src/ public/
4670

@@ -49,6 +73,34 @@ dev: build-all
4973

5074
ship: build-all deploy
5175

76+
preview: RELEASES_DIR = $(VPS_PREVIEW_PATH)/$(SAFE_BRANCH)/releases
77+
preview: TARGET = $(RELEASES_DIR)/$(TIMESTAMP)
78+
preview: build-all
79+
preview:
80+
@echo "\n\n**** Deploying preview of a branch '$(BRANCH)' (safe: $(SAFE_BRANCH)) to $(TARGET)...\n\n"
81+
$(REMOTE_CMD) "mkdir -p $(TARGET)"
82+
rsync -avz --delete ./build/ $(VPS_USER)@$(VPS_HOST):$(TARGET)/
83+
$(REMOTE_CMD) "cd $(RELEASES_DIR) && ln -snf $(TIMESTAMP) current"
84+
@echo "\n\n**** Preview complete.\n\n"
85+
@echo "Open the preview site at: $(PREVIEW_SITE_URL)\n\n"
86+
@echo "\n**** Cleaning up old releases (keep latest 3, skip 'current')...\n"
87+
$(REMOTE_CMD) "bash -c '\
88+
cd $(RELEASES_DIR) && \
89+
echo \"[INFO] Cleaning:\" && \
90+
ls -1 */ \
91+
| sed \"s:/*\\\$$::\" \
92+
| grep \"^2026\" \
93+
| sort -r \
94+
| tail -n +4 \
95+
| xargs -r -I{} echo rm -rf \"{}\"'"
96+
97+
ifeq ($(FORCE_DEPLOY), true)
98+
deploy: RELEASES_DIR = $(VPS_PROD_PATH)/releases
99+
deploy: TARGET = $(RELEASES_DIR)/$(TIMESTAMP)
52100
deploy:
53-
rsync -avz --delete build/ static_content_user@ls.artcz.pl:/home/static_content_user/content/ep26/
54-
101+
@echo "\n\n**** Deploying branch '$(BRANCH)' (safe: $(SAFE_BRANCH)) to $(TARGET)...\n\n"
102+
$(REMOTE_CMD) "mkdir -p $(TARGET)"
103+
rsync -avz --delete ./build/ $(VPS_USER)@$(VPS_HOST):$(TARGET)/
104+
$(REMOTE_CMD) "cd $(RELEASES_DIR) && ln -snf $(TIMESTAMP) current"
105+
@echo "\n\n**** Deployment complete.\n\n"
106+
endif

0 commit comments

Comments
 (0)