From 542886a47e69ae31ca7a8bab188a5ab64fa938bd Mon Sep 17 00:00:00 2001
From: Artur Czepiel
Date: Sun, 19 Jan 2025 13:46:13 +0100
Subject: [PATCH 01/11] test simpler deployment
---
.github/workflows/build-deploy.yml | 20 ++--------
Makefile | 55 +++++++++++++++++++------
deploy.yml | 64 ------------------------------
src/components/footer.astro | 5 +++
4 files changed, 51 insertions(+), 93 deletions(-)
delete mode 100644 deploy.yml
diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml
index dd7b3c346..2ff33f8d9 100644
--- a/.github/workflows/build-deploy.yml
+++ b/.github/workflows/build-deploy.yml
@@ -6,6 +6,7 @@ on:
branches:
- ep2024
- ep2025
+ - deployment-simpler
jobs:
deploy:
@@ -27,19 +28,10 @@ jobs:
cache: "pnpm"
- name: Install dependencies
- run: pnpm install
-
- - name: Set up Python
- uses: actions/setup-python@v5
- with:
- python-version: "3.13"
- cache: "pip"
-
- - name: Install Ansible
- run: pip install ansible
+ run: make install
- name: Build the website
- run: pnpm build
+ run: make build
- name: Set up SSH key
uses: webfactory/ssh-agent@v0.9.0
@@ -47,8 +39,4 @@ jobs:
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
- name: Deploy to server
- env:
- SSH_USERNAME: ${{ secrets.DEPLOY_SSH_USERNAME }}
- INVENTORY: ${{ secrets.DEPLOY_INVENTORY }}
- run: |
- ansible-playbook -u $SSH_USERNAME -i "$INVENTORY" deploy.yml
+ run: make deploy
diff --git a/Makefile b/Makefile
index 9dbdacf03..dc84c9d3f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,36 @@
+#
+# Variables for remote host
+# =========================
+VPS_USER ?= static_content_user
+VPS_HOST ?= static.europython.eu
+VPS_PROD_PATH ?= /home/static_content_user/content/europython_websites/ep2025test
+VPS_PREVIEW_PATH ?= /home/static_content_user/content/europython_websites/previews/
+REMOTE_CMD=ssh $(VPS_USER)@$(VPS_HOST)
+
+# Variables for build/deploy
+# ==========================
+export TIMESTAMP := $(shell date +%Y%m%d%H%M%S)
+export GIT_VERSION := $(shell git rev-parse --short HEAD)
+
+# Variables for deploy
+# ====================
+# Auto-detect and sanitize current git branch
+BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
+# Replace "/" and other non-alphanumeric characters with "-"
+SAFE_BRANCH := $(shell echo "$(BRANCH)" | sed 's/[^A-Za-z0-9._-]/-/g')
+
+# TODO: update this to the prod branches
+ifeq ($(SAFE_BRANCH), deployment-simpler)
+ RELEASES_DIR := $(VPS_PATH)/releases
+else
+ RELEASES_DIR := $(VPS_PATH)/preview/$(SAFE_BRANCH)/releases
+endif
+
+TARGET := $(RELEASES_DIR)/$(TIMESTAMP)
+
+.PHONY: build deploy dev clean install
+
pre:
- python -m pip install pre-commit ansible
- pre-commit install
npm install -g pnpm
install:
@@ -9,17 +39,16 @@ install:
dev:
pnpm dev
-build:
- pnpm build
-
-deploy:
- $(if $(findstring Windows_NT, $(OS)), \
- $(error Deployment is not supported on Windows. Use WSL or a Unix-like system.), \
- @read -p "Enter SSH username: " USERNAME; \
- read -p "Enter inline inventory (e.g., 'host1,' (DO NOT forget the trailing comma)): " INVENTORY; \
- ansible-playbook -u $$USERNAME -i "$$INVENTORY" deploy.yml)
-
clean:
git clean -fdX
-.PHONY: pre install dev build deploy clean
+build:
+ # TODO: update this to just `pnpm build` after resolving the astro-check warnings
+ pnpm run astro build
+
+deploy:
+ @echo "\n\n**** Deploying branch '$(BRANCH)' (safe: $(SAFE_BRANCH)) to $(TARGET)...\n\n"
+ $(REMOTE_CMD) "mkdir -p $(TARGET)"
+ rsync -avz --delete ./dist/ $(VPS_USER)@$(VPS_HOST):$(TARGET)/
+ $(REMOTE_CMD) "cd $(RELEASES_DIR) && ln -snf $(TIMESTAMP) current"
+ @echo "\n\n**** Deployment complete.\n\n"
diff --git a/deploy.yml b/deploy.yml
deleted file mode 100644
index 3f33064b1..000000000
--- a/deploy.yml
+++ /dev/null
@@ -1,64 +0,0 @@
-- name: Deploy content to static server
- hosts: all
- vars:
- branch_list:
- - ep2024
- - ep2025
- branch_name:
- "{{ lookup('pipe', 'git rev-parse --abbrev-ref HEAD') | trim }}"
- sanitized_branch_name:
- "{{ branch_name | regex_replace('[^a-zA-Z0-9_-]', '_') }}"
- remote_base_path: "/home/{{ ansible_user }}/content"
-
- tasks:
- - name: Generate UUID for temp directory
- ansible.builtin.set_fact:
- unique_id: "{{ ansible_date_time.iso8601_micro | to_uuid }}"
-
- - name: Define and trim deploy path
- ansible.builtin.set_fact:
- deploy_path: >-
- {{
- (
- remote_base_path + '/europython_websites/' + branch_name
- if branch_name in branch_list else
- remote_base_path + '/previews/' + sanitized_branch_name
- ) | trim
- }}
- temp_dir: "{{ remote_base_path }}/temp/{{ unique_id }}"
-
- - name: Show deployment configuration
- ansible.builtin.debug:
- msg:
- - "Branch Name: '{{ branch_name }}'"
- - "Sanitized Branch Name: '{{ sanitized_branch_name }}'"
- - "Remote Base Path: '{{ remote_base_path }}'"
- - "Deploy Path: '{{ deploy_path }}'"
- - "Temp Dir: '{{ temp_dir }}'"
-
- - name: Ensure the temporary destination directory exists
- ansible.builtin.file:
- path: "{{ temp_dir }}"
- state: directory
- recurse: true
- mode: 750
-
- - name: Synchronize local files to remote temporary directory
- ansible.posix.synchronize:
- src: dist/
- dest: "{{ deploy_path }}/"
- mode: push
- checksum: true
- delete: true
-
- - name: Verify deployment success
- ansible.builtin.find:
- paths: "{{ deploy_path }}"
- recurse: true
- age: -1d
- register: target_dir_check
- failed_when: target_dir_check.matched == 0
-
- - name: Confirm deployment success
- debug:
- msg: "Files successfully deployed to '{{ deploy_path }}/'."
diff --git a/src/components/footer.astro b/src/components/footer.astro
index b0793476b..f7f8623c5 100644
--- a/src/components/footer.astro
+++ b/src/components/footer.astro
@@ -3,6 +3,9 @@ import { Fullbleed } from "./layout/fullbleed";
import links from "../data/links.json";
import { EPSLogo } from "./logo/eps-logo";
+
+const buildTimestamp = import.meta.env.TIMESTAMP;
+const gitVersion = import.meta.env.GIT_VERSION;
---
@@ -89,5 +92,7 @@ import { EPSLogo } from "./logo/eps-logo";
+
+ version: {gitVersion} @ {buildTimestamp}
From dfa78f00607ffeaec5f35f7c41d59210ba86a591 Mon Sep 17 00:00:00 2001
From: Artur Czepiel
Date: Sun, 19 Jan 2025 13:50:59 +0100
Subject: [PATCH 02/11] ssh keyscan
---
.github/workflows/build-deploy.yml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml
index 2ff33f8d9..cfd17ec5d 100644
--- a/.github/workflows/build-deploy.yml
+++ b/.github/workflows/build-deploy.yml
@@ -38,5 +38,8 @@ jobs:
with:
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
+ - name: ssh keyscan
+ run: ssh-keyscan "static.europython.eu" > ~/.ssh/known_hosts
+
- name: Deploy to server
run: make deploy
From dbaa442bb0361a0c1b8d251424f95b7504b6f581 Mon Sep 17 00:00:00 2001
From: Artur Czepiel
Date: Sun, 19 Jan 2025 13:54:17 +0100
Subject: [PATCH 03/11] fix path
---
Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index dc84c9d3f..768e8882d 100644
--- a/Makefile
+++ b/Makefile
@@ -21,9 +21,9 @@ SAFE_BRANCH := $(shell echo "$(BRANCH)" | sed 's/[^A-Za-z0-9._-]/-/g')
# TODO: update this to the prod branches
ifeq ($(SAFE_BRANCH), deployment-simpler)
- RELEASES_DIR := $(VPS_PATH)/releases
+ RELEASES_DIR := $(VPS_PROD_PATH)/releases
else
- RELEASES_DIR := $(VPS_PATH)/preview/$(SAFE_BRANCH)/releases
+ RELEASES_DIR := $(VPS_PROD_PATH)/preview/$(SAFE_BRANCH)/releases
endif
TARGET := $(RELEASES_DIR)/$(TIMESTAMP)
From ff817959ce57a64d6827598c663953d2087cdf54 Mon Sep 17 00:00:00 2001
From: Artur Czepiel
Date: Sun, 19 Jan 2025 14:15:54 +0100
Subject: [PATCH 04/11] add timestamp
---
.github/workflows/build-deploy.yml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml
index cfd17ec5d..6403aa1c1 100644
--- a/.github/workflows/build-deploy.yml
+++ b/.github/workflows/build-deploy.yml
@@ -16,6 +16,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
+ - name: Set timestamp for build/deploy
+ run: |
+ TIMESTAMP=$(date +%Y%m%d%H%M%S)
+ echo "TIMESTAMP=${TIMESTAMP}" >> $GITHUB_ENV
+
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
From e2c2688fb376ecf291deb8ed07676a34a1a197ff Mon Sep 17 00:00:00 2001
From: Artur Czepiel
Date: Sun, 19 Jan 2025 14:25:11 +0100
Subject: [PATCH 05/11] simplify timestamp
---
.github/workflows/build-deploy.yml | 4 +---
Makefile | 4 ++--
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml
index 6403aa1c1..8421b1718 100644
--- a/.github/workflows/build-deploy.yml
+++ b/.github/workflows/build-deploy.yml
@@ -17,9 +17,7 @@ jobs:
uses: actions/checkout@v4
- name: Set timestamp for build/deploy
- run: |
- TIMESTAMP=$(date +%Y%m%d%H%M%S)
- echo "TIMESTAMP=${TIMESTAMP}" >> $GITHUB_ENV
+ run: echo "TIMESTAMP=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
- name: Set up pnpm
uses: pnpm/action-setup@v4
diff --git a/Makefile b/Makefile
index 768e8882d..3ff541a3e 100644
--- a/Makefile
+++ b/Makefile
@@ -9,8 +9,8 @@ REMOTE_CMD=ssh $(VPS_USER)@$(VPS_HOST)
# Variables for build/deploy
# ==========================
-export TIMESTAMP := $(shell date +%Y%m%d%H%M%S)
-export GIT_VERSION := $(shell git rev-parse --short HEAD)
+export TIMESTAMP ?= $(shell date +%Y%m%d%H%M%S)
+export GIT_VERSION ?= $(shell git rev-parse --short HEAD)
# Variables for deploy
# ====================
From 7dc2670bd0506b578cfa96cf32c32f07d9dbfbed Mon Sep 17 00:00:00 2001
From: Artur Czepiel
Date: Sun, 19 Jan 2025 15:48:14 +0100
Subject: [PATCH 06/11] remove original jpg files from dist
---
Makefile | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Makefile b/Makefile
index 3ff541a3e..3657fd7ea 100644
--- a/Makefile
+++ b/Makefile
@@ -45,6 +45,8 @@ clean:
build:
# TODO: update this to just `pnpm build` after resolving the astro-check warnings
pnpm run astro build
+ # NOTE: also let's find a better way to do this :D
+ find ./dist/_astro/ -iname '*.jpg' -delete
deploy:
@echo "\n\n**** Deploying branch '$(BRANCH)' (safe: $(SAFE_BRANCH)) to $(TARGET)...\n\n"
From 360c8984b24dad06681441f1a550aa8ad0de4122 Mon Sep 17 00:00:00 2001
From: Artur Czepiel
Date: Sun, 19 Jan 2025 16:13:17 +0100
Subject: [PATCH 07/11] add conditional flag for deployment
---
.github/workflows/build-deploy.yml | 2 +-
Makefile | 13 ++++++++-----
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml
index 8421b1718..0388e1ce8 100644
--- a/.github/workflows/build-deploy.yml
+++ b/.github/workflows/build-deploy.yml
@@ -45,4 +45,4 @@ jobs:
run: ssh-keyscan "static.europython.eu" > ~/.ssh/known_hosts
- name: Deploy to server
- run: make deploy
+ run: make deploy FORCE_DEPLOY=true
diff --git a/Makefile b/Makefile
index 3657fd7ea..810d1d8d4 100644
--- a/Makefile
+++ b/Makefile
@@ -18,6 +18,7 @@ export GIT_VERSION ?= $(shell git rev-parse --short HEAD)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
# Replace "/" and other non-alphanumeric characters with "-"
SAFE_BRANCH := $(shell echo "$(BRANCH)" | sed 's/[^A-Za-z0-9._-]/-/g')
+FORCE_DEPLOY ?= false
# TODO: update this to the prod branches
ifeq ($(SAFE_BRANCH), deployment-simpler)
@@ -48,9 +49,11 @@ build:
# NOTE: also let's find a better way to do this :D
find ./dist/_astro/ -iname '*.jpg' -delete
+ifeq ($(FORCE_DEPLOY), true)
deploy:
- @echo "\n\n**** Deploying branch '$(BRANCH)' (safe: $(SAFE_BRANCH)) to $(TARGET)...\n\n"
- $(REMOTE_CMD) "mkdir -p $(TARGET)"
- rsync -avz --delete ./dist/ $(VPS_USER)@$(VPS_HOST):$(TARGET)/
- $(REMOTE_CMD) "cd $(RELEASES_DIR) && ln -snf $(TIMESTAMP) current"
- @echo "\n\n**** Deployment complete.\n\n"
+ @echo "\n\n**** Deploying branch '$(BRANCH)' (safe: $(SAFE_BRANCH)) to $(TARGET)...\n\n"
+ $(REMOTE_CMD) "mkdir -p $(TARGET)"
+ rsync -avz --delete ./dist/ $(VPS_USER)@$(VPS_HOST):$(TARGET)/
+ $(REMOTE_CMD) "cd $(RELEASES_DIR) && ln -snf $(TIMESTAMP) current"
+ @echo "\n\n**** Deployment complete.\n\n"
+endif
From f6cc7f6791bad557d12aff3ded81a2f19164c35a Mon Sep 17 00:00:00 2001
From: Artur Czepiel
Date: Sun, 19 Jan 2025 16:37:17 +0100
Subject: [PATCH 08/11] update paths
---
Makefile | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile
index 810d1d8d4..e32325f9a 100644
--- a/Makefile
+++ b/Makefile
@@ -3,8 +3,8 @@
# =========================
VPS_USER ?= static_content_user
VPS_HOST ?= static.europython.eu
-VPS_PROD_PATH ?= /home/static_content_user/content/europython_websites/ep2025test
-VPS_PREVIEW_PATH ?= /home/static_content_user/content/europython_websites/previews/
+VPS_PROD_PATH ?= /home/static_content_user/content/europython_websites/ep2025
+VPS_PREVIEW_PATH ?= /home/static_content_user/content/previews/
REMOTE_CMD=ssh $(VPS_USER)@$(VPS_HOST)
# Variables for build/deploy
@@ -21,7 +21,7 @@ SAFE_BRANCH := $(shell echo "$(BRANCH)" | sed 's/[^A-Za-z0-9._-]/-/g')
FORCE_DEPLOY ?= false
# TODO: update this to the prod branches
-ifeq ($(SAFE_BRANCH), deployment-simpler)
+ifeq ($(SAFE_BRANCH), ep2025)
RELEASES_DIR := $(VPS_PROD_PATH)/releases
else
RELEASES_DIR := $(VPS_PROD_PATH)/preview/$(SAFE_BRANCH)/releases
@@ -43,6 +43,9 @@ dev:
clean:
git clean -fdX
+check:
+ pnpm run astro check
+
build:
# TODO: update this to just `pnpm build` after resolving the astro-check warnings
pnpm run astro build
@@ -51,9 +54,9 @@ build:
ifeq ($(FORCE_DEPLOY), true)
deploy:
- @echo "\n\n**** Deploying branch '$(BRANCH)' (safe: $(SAFE_BRANCH)) to $(TARGET)...\n\n"
- $(REMOTE_CMD) "mkdir -p $(TARGET)"
- rsync -avz --delete ./dist/ $(VPS_USER)@$(VPS_HOST):$(TARGET)/
- $(REMOTE_CMD) "cd $(RELEASES_DIR) && ln -snf $(TIMESTAMP) current"
- @echo "\n\n**** Deployment complete.\n\n"
+ @echo "\n\n**** Deploying branch '$(BRANCH)' (safe: $(SAFE_BRANCH)) to $(TARGET)...\n\n"
+ $(REMOTE_CMD) "mkdir -p $(TARGET)"
+ rsync -avz --delete ./dist/ $(VPS_USER)@$(VPS_HOST):$(TARGET)/
+ $(REMOTE_CMD) "cd $(RELEASES_DIR) && ln -snf $(TIMESTAMP) current"
+ @echo "\n\n**** Deployment complete.\n\n"
endif
From 223b34c4b585d1271f36ad4267d9287d85eff9d3 Mon Sep 17 00:00:00 2001
From: Artur Czepiel
Date: Sun, 19 Jan 2025 16:38:42 +0100
Subject: [PATCH 09/11] fix previous
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index e32325f9a..aeffeab14 100644
--- a/Makefile
+++ b/Makefile
@@ -24,7 +24,7 @@ FORCE_DEPLOY ?= false
ifeq ($(SAFE_BRANCH), ep2025)
RELEASES_DIR := $(VPS_PROD_PATH)/releases
else
- RELEASES_DIR := $(VPS_PROD_PATH)/preview/$(SAFE_BRANCH)/releases
+ RELEASES_DIR := $(VPS_PREVIEW_PATH)/$(SAFE_BRANCH)/releases
endif
TARGET := $(RELEASES_DIR)/$(TIMESTAMP)
From 168266a4bddf11194225485d58258e58bc3abee3 Mon Sep 17 00:00:00 2001
From: Artur Czepiel
Date: Mon, 20 Jan 2025 17:15:48 +0100
Subject: [PATCH 10/11] add previews (#966)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Cyril Bitterich
---
.github/workflows/preview.yml | 102 ++++++++++++++++++++++++++++++++++
Makefile | 28 ++++++----
src/components/footer.astro | 2 +-
3 files changed, 121 insertions(+), 11 deletions(-)
create mode 100644 .github/workflows/preview.yml
diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml
new file mode 100644
index 000000000..8998fa3b1
--- /dev/null
+++ b/.github/workflows/preview.yml
@@ -0,0 +1,102 @@
+name: Preview
+
+on:
+ pull_request:
+
+jobs:
+ preview:
+ name: Run preview
+ runs-on: ubuntu-latest
+ env:
+ PREVIEW_HOSTNAME: ep-preview.click
+ GITHUB_BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Set timestamp for build/deploy
+ run: echo "TIMESTAMP=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
+
+ - name: Set up pnpm
+ uses: pnpm/action-setup@v4
+ with:
+ run_install: false
+
+ - name: Set up Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: 20
+ cache: "pnpm"
+
+ - name: Install dependencies
+ run: make install
+
+ - name: Build the website
+ run: make build
+
+ - name: Set up SSH key
+ uses: webfactory/ssh-agent@v0.9.0
+ with:
+ ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
+
+ - name: Get current branch name
+ run: |
+ BRANCH_NAME=$(make safe_branch BRANCH=$GITHUB_BRANCH_NAME)
+ echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
+
+ - name: ssh keyscan
+ run: ssh-keyscan "static.europython.eu" > ~/.ssh/known_hosts
+
+ - name: Upload preview
+ run: make preview BRANCH=$GITHUB_BRANCH_NAME
+
+ - name: Update PR Comment
+ uses: actions/github-script@v6
+ if: github.event_name == 'pull_request'
+
+ with:
+ github-token: ${{ secrets.GITHUB_TOKEN }}
+ script: |
+ console.log("Hello world!");
+ const pr_id = ${{ github.event.number }};
+ console.log("PR Id %d", pr_id);
+
+ comments = await github.paginate(github.rest.issues.listComments, {
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: Number(pr_id)
+ })
+
+ const preview_identifier = "# Preview available"
+
+ let comment_id = null;
+ comments.forEach(comment => {
+ if(comment.body.indexOf(preview_identifier) >= 0) {
+ comment_id = comment.id;
+ }
+ });
+
+ const branch_name = process.env.BRANCH_NAME;
+ const url = "https://" + branch_name + "." + process.env.PREVIEW_HOSTNAME;
+ const timestamp = new Date().toISOString();
+ const header = "\n|Key|Value|\n|---|---|\n"
+ const body = preview_identifier + header + "|url|" + url + "|\n|last update|" + timestamp + "|";
+
+ if(comment_id > 0) {
+ await github.rest.issues.updateComment({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ comment_id: comment_id,
+ body: body
+ });
+
+ } else {
+
+ await github.rest.issues.createComment({
+ issue_number: Number(pr_id),
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ body: body
+ });
+ }
diff --git a/Makefile b/Makefile
index aeffeab14..612dfadee 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@
VPS_USER ?= static_content_user
VPS_HOST ?= static.europython.eu
VPS_PROD_PATH ?= /home/static_content_user/content/europython_websites/ep2025
-VPS_PREVIEW_PATH ?= /home/static_content_user/content/previews/
+VPS_PREVIEW_PATH ?= /home/static_content_user/content/previews
REMOTE_CMD=ssh $(VPS_USER)@$(VPS_HOST)
# Variables for build/deploy
@@ -15,21 +15,16 @@ export GIT_VERSION ?= $(shell git rev-parse --short HEAD)
# Variables for deploy
# ====================
# Auto-detect and sanitize current git branch
-BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
+BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
# Replace "/" and other non-alphanumeric characters with "-"
SAFE_BRANCH := $(shell echo "$(BRANCH)" | sed 's/[^A-Za-z0-9._-]/-/g')
FORCE_DEPLOY ?= false
-# TODO: update this to the prod branches
-ifeq ($(SAFE_BRANCH), ep2025)
- RELEASES_DIR := $(VPS_PROD_PATH)/releases
-else
- RELEASES_DIR := $(VPS_PREVIEW_PATH)/$(SAFE_BRANCH)/releases
-endif
+.PHONY: build deploy dev clean install
-TARGET := $(RELEASES_DIR)/$(TIMESTAMP)
-.PHONY: build deploy dev clean install
+safe_branch:
+ @echo $(SAFE_BRANCH)
pre:
npm install -g pnpm
@@ -52,7 +47,20 @@ build:
# NOTE: also let's find a better way to do this :D
find ./dist/_astro/ -iname '*.jpg' -delete
+preview: RELEASES_DIR = $(VPS_PREVIEW_PATH)/$(SAFE_BRANCH)/releases
+preview: TARGET = $(RELEASES_DIR)/$(TIMESTAMP)
+preview:
+ echo $(TARGET)
+ @echo "\n\n**** Deploying preview of a branch '$(BRANCH)' (safe: $(SAFE_BRANCH)) to $(TARGET)...\n\n"
+ $(REMOTE_CMD) "mkdir -p $(TARGET)"
+ rsync -avz --delete ./dist/ $(VPS_USER)@$(VPS_HOST):$(TARGET)/
+ $(REMOTE_CMD) "cd $(RELEASES_DIR) && ln -snf $(TIMESTAMP) current"
+ @echo "\n\n**** Preview complete.\n\n"
+
+
ifeq ($(FORCE_DEPLOY), true)
+deploy: RELEASES_DIR = $(VPS_PROD_PATH)/$(SAFE_BRANCH)/releases
+deploy: TARGET = $(RELEASES_DIR)/$(TIMESTAMP)
deploy:
@echo "\n\n**** Deploying branch '$(BRANCH)' (safe: $(SAFE_BRANCH)) to $(TARGET)...\n\n"
$(REMOTE_CMD) "mkdir -p $(TARGET)"
diff --git a/src/components/footer.astro b/src/components/footer.astro
index f7f8623c5..0d4aad64d 100644
--- a/src/components/footer.astro
+++ b/src/components/footer.astro
@@ -93,6 +93,6 @@ const gitVersion = import.meta.env.GIT_VERSION;
- version: {gitVersion} @ {buildTimestamp}
+ version: {gitVersion} @ {buildTimestamp}
From 9afbea4322da9fda9d2f99f82192c99279c8f08b Mon Sep 17 00:00:00 2001
From: Artur Czepiel
Date: Mon, 20 Jan 2025 17:17:49 +0100
Subject: [PATCH 11/11] deploy only ep2025
---
.github/workflows/build-deploy.yml | 2 --
1 file changed, 2 deletions(-)
diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml
index 0388e1ce8..643969638 100644
--- a/.github/workflows/build-deploy.yml
+++ b/.github/workflows/build-deploy.yml
@@ -4,9 +4,7 @@ on:
workflow_dispatch:
push:
branches:
- - ep2024
- ep2025
- - deployment-simpler
jobs:
deploy: