diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index b0fd68b1e..98306415c 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -54,6 +54,12 @@ jobs: BRANCH: "${{ env.GITHUB_BRANCH_NAME }}" run: make preview + - name: Get safe branch and export to env + env: + BRANCH: ${{ env.GITHUB_BRANCH_NAME }} + run: | + echo "SAFE_BRANCH=$(make safe_branch)" >> $GITHUB_ENV + - name: Update PR Comment uses: actions/github-script@v7 if: github.event_name == 'pull_request' @@ -80,8 +86,8 @@ jobs: } }); - const branch_name = process.env.GITHUB_BRANCH_NAME; - const url = "https://" + branch_name + "." + process.env.PREVIEW_HOSTNAME; + const safe_branch = process.env.SAFE_BRANCH; + const url = "https://" + safe_branch + "." + 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 + "|"; diff --git a/Makefile b/Makefile index 37b1b7c9a..2d16e8e8f 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ export GIT_VERSION ?= $(shell git rev-parse --short HEAD) # 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') +SAFE_BRANCH := $(shell echo "$(BRANCH)" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g') FORCE_DEPLOY ?= false SITE_URL ?= "https://$(SAFE_BRANCH).ep-preview.click"