Skip to content

Commit 542886a

Browse files
committed
test simpler deployment
1 parent 8587889 commit 542886a

File tree

4 files changed

+51
-93
lines changed

4 files changed

+51
-93
lines changed

.github/workflows/build-deploy.yml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
branches:
77
- ep2024
88
- ep2025
9+
- deployment-simpler
910

1011
jobs:
1112
deploy:
@@ -27,28 +28,15 @@ jobs:
2728
cache: "pnpm"
2829

2930
- name: Install dependencies
30-
run: pnpm install
31-
32-
- name: Set up Python
33-
uses: actions/setup-python@v5
34-
with:
35-
python-version: "3.13"
36-
cache: "pip"
37-
38-
- name: Install Ansible
39-
run: pip install ansible
31+
run: make install
4032

4133
- name: Build the website
42-
run: pnpm build
34+
run: make build
4335

4436
- name: Set up SSH key
4537
uses: webfactory/ssh-agent@v0.9.0
4638
with:
4739
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
4840

4941
- name: Deploy to server
50-
env:
51-
SSH_USERNAME: ${{ secrets.DEPLOY_SSH_USERNAME }}
52-
INVENTORY: ${{ secrets.DEPLOY_INVENTORY }}
53-
run: |
54-
ansible-playbook -u $SSH_USERNAME -i "$INVENTORY" deploy.yml
42+
run: make deploy

Makefile

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
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+
133
pre:
2-
python -m pip install pre-commit ansible
3-
pre-commit install
434
npm install -g pnpm
535

636
install:
@@ -9,17 +39,16 @@ install:
939
dev:
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-
2242
clean:
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"

deploy.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.

src/components/footer.astro

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { Fullbleed } from "./layout/fullbleed";
33
44
import links from "../data/links.json";
55
import { EPSLogo } from "./logo/eps-logo";
6+
7+
const buildTimestamp = import.meta.env.TIMESTAMP;
8+
const gitVersion = import.meta.env.GIT_VERSION;
69
---
710

811
<Fullbleed className="bg-primary text-white">
@@ -89,5 +92,7 @@ import { EPSLogo } from "./logo/eps-logo";
8992
</p>
9093
</div>
9194
</article>
95+
96+
<p>version: {gitVersion} @ {buildTimestamp}</p>
9297
</footer>
9398
</Fullbleed>

0 commit comments

Comments
 (0)