From c3b48e033960ade0b17f05ea12815641b47ff42d Mon Sep 17 00:00:00 2001 From: egeakman Date: Wed, 15 Jan 2025 02:20:48 -0500 Subject: [PATCH 01/18] Add deployment logic --- .github/workflows/build-deploy.yml | 54 ++++++++++++++++++++++ Makefile | 8 ++-- deploy.yml | 72 ++++++++++++++++++++++++++++++ 3 files changed, 131 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build-deploy.yml create mode 100644 deploy.yml diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml new file mode 100644 index 000000000..dd7b3c346 --- /dev/null +++ b/.github/workflows/build-deploy.yml @@ -0,0 +1,54 @@ +name: Deploy to Server + +on: + workflow_dispatch: + push: + branches: + - ep2024 + - ep2025 + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - 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: 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 + + - name: Build the website + run: pnpm build + + - name: Set up SSH key + uses: webfactory/ssh-agent@v0.9.0 + with: + 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 diff --git a/Makefile b/Makefile index ac5ac0a9a..9dbdacf03 100644 --- a/Makefile +++ b/Makefile @@ -13,9 +13,11 @@ build: pnpm build deploy: - $(if $(FORCE),$(if $(filter 1,$(FORCE)), \ - @echo TO BE IMPLEMENTED, \ - $(error FORCE must be set to 1)),$(error Use 'make deploy FORCE=1' to 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 diff --git a/deploy.yml b/deploy.yml new file mode 100644 index 000000000..29fab3cd2 --- /dev/null +++ b/deploy.yml @@ -0,0 +1,72 @@ +- 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 + set_fact: + unique_id: "{{ lookup('pipe', 'uuidgen') }}" + + - name: Define and trim deploy path + 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/temp_{{ sanitized_branch_name }}_{{ + unique_id }}" + + - name: Show deployment configuration + 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 + file: + path: "{{ temp_dir }}" + state: directory + + - name: Synchronize local files to remote temporary directory + synchronize: + src: dist/ + dest: "{{ temp_dir }}/" + mode: push + rsync_opts: + - "--delete" + + - name: Ensure temporary directory is populated + shell: test "$(ls -A {{ temp_dir }})" + register: temp_dir_check + failed_when: temp_dir_check.rc != 0 + + - name: Copy files from temporary directory to deployment directory + shell: rsync -a --delete {{ temp_dir }}/ {{ deploy_path }}/ + + - name: Verify deployment success + shell: | + if [ ! -d "{{ deploy_path }}" ] || [ -z "$(ls -A {{ deploy_path }})" ]; then + exit 1 + fi + register: target_dir_check + failed_when: target_dir_check.rc != 0 + + - name: Confirm deployment success + debug: + msg: "Files successfully deployed to '{{ deploy_path }}/'." From dbc36cf6a4b35fb0e2197e9db0fa7dea5b0fcdc4 Mon Sep 17 00:00:00 2001 From: Cyril Bitterich Date: Fri, 17 Jan 2025 23:05:03 +0100 Subject: [PATCH 02/18] Update deploy.yml --- deploy.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deploy.yml b/deploy.yml index 29fab3cd2..dfe45dbdf 100644 --- a/deploy.yml +++ b/deploy.yml @@ -42,6 +42,8 @@ file: path: "{{ temp_dir }}" state: directory + recurse: true + mode: 750 - name: Synchronize local files to remote temporary directory synchronize: From 5f114552a1ebce14983ba302ddd4abd86b259dd9 Mon Sep 17 00:00:00 2001 From: Cyril Bitterich Date: Fri, 17 Jan 2025 23:05:09 +0100 Subject: [PATCH 03/18] Update deploy.yml --- deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy.yml b/deploy.yml index dfe45dbdf..808735196 100644 --- a/deploy.yml +++ b/deploy.yml @@ -39,7 +39,7 @@ - "Temp Dir: '{{ temp_dir }}'" - name: Ensure the temporary destination directory exists - file: + ansible.builtin.file: path: "{{ temp_dir }}" state: directory recurse: true From b4182ff2bed3a6e6695bb770cfbc945b3d6b050c Mon Sep 17 00:00:00 2001 From: Cyril Bitterich Date: Fri, 17 Jan 2025 23:05:16 +0100 Subject: [PATCH 04/18] Update deploy.yml --- deploy.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/deploy.yml b/deploy.yml index 808735196..ae625f0be 100644 --- a/deploy.yml +++ b/deploy.yml @@ -50,8 +50,7 @@ src: dist/ dest: "{{ temp_dir }}/" mode: push - rsync_opts: - - "--delete" + delete: true - name: Ensure temporary directory is populated shell: test "$(ls -A {{ temp_dir }})" From 4a7799c67ab14664d94b1fc1eea014dfa16b34c1 Mon Sep 17 00:00:00 2001 From: Cyril Bitterich Date: Fri, 17 Jan 2025 23:05:23 +0100 Subject: [PATCH 05/18] Update deploy.yml --- deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy.yml b/deploy.yml index ae625f0be..dd9317d77 100644 --- a/deploy.yml +++ b/deploy.yml @@ -16,7 +16,7 @@ unique_id: "{{ lookup('pipe', 'uuidgen') }}" - name: Define and trim deploy path - set_fact: + ansible.builtin.set_fact: deploy_path: >- {{ ( From 7cf4f8162f4775b648f91ae026999276a32d2b4b Mon Sep 17 00:00:00 2001 From: Cyril Bitterich Date: Fri, 17 Jan 2025 23:05:32 +0100 Subject: [PATCH 06/18] Update deploy.yml --- deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy.yml b/deploy.yml index dd9317d77..675537540 100644 --- a/deploy.yml +++ b/deploy.yml @@ -30,7 +30,7 @@ unique_id }}" - name: Show deployment configuration - debug: + ansible.builtin.debug: msg: - "Branch Name: '{{ branch_name }}'" - "Sanitized Branch Name: '{{ sanitized_branch_name }}'" From 9af2130584b25787a85d6db77c1de248d358508e Mon Sep 17 00:00:00 2001 From: Cyril Bitterich Date: Fri, 17 Jan 2025 23:05:50 +0100 Subject: [PATCH 07/18] Update deploy.yml --- deploy.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/deploy.yml b/deploy.yml index 675537540..50ce2bab3 100644 --- a/deploy.yml +++ b/deploy.yml @@ -52,14 +52,6 @@ mode: push delete: true - - name: Ensure temporary directory is populated - shell: test "$(ls -A {{ temp_dir }})" - register: temp_dir_check - failed_when: temp_dir_check.rc != 0 - - - name: Copy files from temporary directory to deployment directory - shell: rsync -a --delete {{ temp_dir }}/ {{ deploy_path }}/ - - name: Verify deployment success shell: | if [ ! -d "{{ deploy_path }}" ] || [ -z "$(ls -A {{ deploy_path }})" ]; then From 6773634113035146a943874d632e82b18649d234 Mon Sep 17 00:00:00 2001 From: Cyril Bitterich Date: Fri, 17 Jan 2025 23:05:57 +0100 Subject: [PATCH 08/18] Update deploy.yml --- deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy.yml b/deploy.yml index 50ce2bab3..2fcee9888 100644 --- a/deploy.yml +++ b/deploy.yml @@ -58,7 +58,7 @@ exit 1 fi register: target_dir_check - failed_when: target_dir_check.rc != 0 + failed_when: target_dir_check.matched == 0 - name: Confirm deployment success debug: From 53665765bfa523eb6c92a83f182d248ade91403d Mon Sep 17 00:00:00 2001 From: Cyril Bitterich Date: Fri, 17 Jan 2025 23:06:08 +0100 Subject: [PATCH 09/18] Update deploy.yml --- deploy.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deploy.yml b/deploy.yml index 2fcee9888..577f04e64 100644 --- a/deploy.yml +++ b/deploy.yml @@ -53,10 +53,10 @@ delete: true - name: Verify deployment success - shell: | - if [ ! -d "{{ deploy_path }}" ] || [ -z "$(ls -A {{ deploy_path }})" ]; then - exit 1 - fi + ansible.builtin.find: + paths: "{{ deploy_path }}" + recurse: true + age: -1d register: target_dir_check failed_when: target_dir_check.matched == 0 From 90d34fb0815c4ed516dd5770502c1d58df51d490 Mon Sep 17 00:00:00 2001 From: Cyril Bitterich Date: Fri, 17 Jan 2025 23:06:16 +0100 Subject: [PATCH 10/18] Update deploy.yml --- deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy.yml b/deploy.yml index 577f04e64..5c4857149 100644 --- a/deploy.yml +++ b/deploy.yml @@ -12,7 +12,7 @@ tasks: - name: Generate UUID for temp directory - set_fact: + ansible.builtin.set_fact: unique_id: "{{ lookup('pipe', 'uuidgen') }}" - name: Define and trim deploy path From e53780f7c23923c9194097331dfbb0b464bf5996 Mon Sep 17 00:00:00 2001 From: Cyril Bitterich Date: Fri, 17 Jan 2025 23:06:30 +0100 Subject: [PATCH 11/18] Update deploy.yml --- deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy.yml b/deploy.yml index 5c4857149..b0fd7d4ac 100644 --- a/deploy.yml +++ b/deploy.yml @@ -46,7 +46,7 @@ mode: 750 - name: Synchronize local files to remote temporary directory - synchronize: + ansible.posix.synchronize: src: dist/ dest: "{{ temp_dir }}/" mode: push From 0bd390d365ffc5ac102b9b0488a5c9c1e2dc51f4 Mon Sep 17 00:00:00 2001 From: Cyril Bitterich Date: Fri, 17 Jan 2025 23:07:06 +0100 Subject: [PATCH 12/18] Update deploy.yml --- deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/deploy.yml b/deploy.yml index b0fd7d4ac..d0919d80a 100644 --- a/deploy.yml +++ b/deploy.yml @@ -50,6 +50,7 @@ src: dist/ dest: "{{ temp_dir }}/" mode: push + checksum: true delete: true - name: Verify deployment success From 80f5ef8090803db34025a55c4b3f11022a71fddb Mon Sep 17 00:00:00 2001 From: Cyril Bitterich Date: Fri, 17 Jan 2025 23:07:19 +0100 Subject: [PATCH 13/18] Update deploy.yml --- deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy.yml b/deploy.yml index d0919d80a..508e1aad2 100644 --- a/deploy.yml +++ b/deploy.yml @@ -48,7 +48,7 @@ - name: Synchronize local files to remote temporary directory ansible.posix.synchronize: src: dist/ - dest: "{{ temp_dir }}/" + dest: "{{ deploy_path }}/" mode: push checksum: true delete: true From 7a624cc67eb716dcdb37d93228a59029a196c84d Mon Sep 17 00:00:00 2001 From: Cyril Bitterich Date: Fri, 17 Jan 2025 23:07:58 +0100 Subject: [PATCH 14/18] Update deploy.yml --- deploy.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/deploy.yml b/deploy.yml index 508e1aad2..2af29a2e1 100644 --- a/deploy.yml +++ b/deploy.yml @@ -26,8 +26,7 @@ ) | trim }} temp_dir: - "{{ remote_base_path }}/temp/temp_{{ sanitized_branch_name }}_{{ - unique_id }}" + "{{ remote_base_path }}/temp/{{ unique_id }}" - name: Show deployment configuration ansible.builtin.debug: From 00b5d1121dc2f7d2a73a6e2d9391353b0753cd6e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 17 Jan 2025 22:10:11 +0000 Subject: [PATCH 15/18] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- deploy.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/deploy.yml b/deploy.yml index 2af29a2e1..2e0a15c94 100644 --- a/deploy.yml +++ b/deploy.yml @@ -25,8 +25,7 @@ remote_base_path + '/previews/' + sanitized_branch_name ) | trim }} - temp_dir: - "{{ remote_base_path }}/temp/{{ unique_id }}" + temp_dir: "{{ remote_base_path }}/temp/{{ unique_id }}" - name: Show deployment configuration ansible.builtin.debug: @@ -49,7 +48,7 @@ src: dist/ dest: "{{ deploy_path }}/" mode: push - checksum: true + checksum: true delete: true - name: Verify deployment success From 3ea643de9b381ab2a25bdc07b750b6a6217cb692 Mon Sep 17 00:00:00 2001 From: Cyril Bitterich Date: Fri, 17 Jan 2025 23:31:42 +0100 Subject: [PATCH 16/18] Update deploy.yml --- deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy.yml b/deploy.yml index 2e0a15c94..3f33064b1 100644 --- a/deploy.yml +++ b/deploy.yml @@ -13,7 +13,7 @@ tasks: - name: Generate UUID for temp directory ansible.builtin.set_fact: - unique_id: "{{ lookup('pipe', 'uuidgen') }}" + unique_id: "{{ ansible_date_time.iso8601_micro | to_uuid }}" - name: Define and trim deploy path ansible.builtin.set_fact: From f291dca58eb21b0e154f566cc68413641d652eb1 Mon Sep 17 00:00:00 2001 From: Artur Czepiel Date: Mon, 20 Jan 2025 17:23:06 +0100 Subject: [PATCH 17/18] test simpler deployment (#965) PR opened for testing if this even works via GHA :) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Cyril Bitterich --- .github/workflows/build-deploy.yml | 26 +++----- .github/workflows/preview.yml | 102 +++++++++++++++++++++++++++++ Makefile | 69 +++++++++++++++---- deploy.yml | 64 ------------------ src/components/footer.astro | 5 ++ 5 files changed, 173 insertions(+), 93 deletions(-) create mode 100644 .github/workflows/preview.yml delete mode 100644 deploy.yml diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index dd7b3c346..643969638 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -4,7 +4,6 @@ on: workflow_dispatch: push: branches: - - ep2024 - ep2025 jobs: @@ -15,6 +14,9 @@ jobs: - name: Checkout repository 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: @@ -27,28 +29,18 @@ 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 with: ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }} + - name: ssh keyscan + run: ssh-keyscan "static.europython.eu" > ~/.ssh/known_hosts + - 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 FORCE_DEPLOY=true 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 9dbdacf03..612dfadee 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,32 @@ +# +# Variables for remote host +# ========================= +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 +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') +FORCE_DEPLOY ?= false + +.PHONY: build deploy dev clean install + + +safe_branch: + @echo $(SAFE_BRANCH) + pre: - python -m pip install pre-commit ansible - pre-commit install npm install -g pnpm install: @@ -9,17 +35,36 @@ install: dev: pnpm dev +clean: + git clean -fdX + +check: + pnpm run astro check + build: - pnpm 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: - $(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) +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" -clean: - git clean -fdX -.PHONY: pre install dev build deploy clean +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)" + 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 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..0d4aad64d 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 3692aee36f0f81b05006ef3e75e7e1cd19fc45f1 Mon Sep 17 00:00:00 2001 From: Artur Czepiel Date: Mon, 20 Jan 2025 17:33:17 +0100 Subject: [PATCH 18/18] Update src/components/footer.astro Co-authored-by: Cyril Bitterich --- src/components/footer.astro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/footer.astro b/src/components/footer.astro index 0d4aad64d..17d982879 100644 --- a/src/components/footer.astro +++ b/src/components/footer.astro @@ -90,9 +90,9 @@ const gitVersion = import.meta.env.GIT_VERSION; github.com/europython

+

version: {gitVersion} @ {buildTimestamp}

-

version: {gitVersion} @ {buildTimestamp}