diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 9a5ce6118..36a27f899 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -32,19 +32,21 @@ jobs: - name: Install dependencies run: make install + - name: Get current branch name + run: | + BRANCH_NAME=$(make safe_branch BRANCH=$GITHUB_BRANCH_NAME) + echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV + - name: Build the website - run: make build PREVIEW=true + run: + make build PREVIEW=true + SITE_URL="https://${BRANCH_NAME}.ep-preview.click" - name: Set up SSH key uses: webfactory/ssh-agent@v0.9.1 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 diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 17be91956..d4040f59c 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -20,6 +20,6 @@ build: commands: - npm install -g pnpm@latest-10 - make install - - make build PREVIEW=true + - make build PREVIEW=true SITE_URL=$READTHEDOCS_CANONICAL_URL - mkdir -p $READTHEDOCS_OUTPUT/html - cd dist && cp -r * $READTHEDOCS_OUTPUT/html diff --git a/Makefile b/Makefile index e434ba371..acf7bfc2e 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ 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) +PREVIEW_SITE_URL ?= "https://$(SAFE_BRANCH).ep-preview.click" # Variables for build/deploy # ========================== @@ -47,13 +48,14 @@ build: preview: RELEASES_DIR = $(VPS_PREVIEW_PATH)/$(SAFE_BRANCH)/releases preview: TARGET = $(RELEASES_DIR)/$(TIMESTAMP) preview: - @echo "Preview site URL: $(SITE_URL)" # Output preview URL + @echo "Preview site URL: $(PREVIEW_SITE_URL)" 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" + @echo "Open the preview site at: $(PREVIEW_SITE_URL)\n\n" ifeq ($(FORCE_DEPLOY), true)