From 52be752d5d83a88367e5cdc742290d3a3b20dd29 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 26 Feb 2025 08:13:43 +0100 Subject: [PATCH 1/2] deploy: define the base URL as an environment variable This will make a subsequent patch easier to understand, where we work around a misconfiguration of git-scm.com that won't let us enforce HTTPS in the GitHub UI at https://github.com/git/git-scm.com/settings/pages. Signed-off-by: Johannes Schindelin --- .github/actions/deploy-to-github-pages/action.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/actions/deploy-to-github-pages/action.yml b/.github/actions/deploy-to-github-pages/action.yml index d11464ed94..ac0d01424d 100644 --- a/.github/actions/deploy-to-github-pages/action.yml +++ b/.github/actions/deploy-to-github-pages/action.yml @@ -47,6 +47,7 @@ runs: set -x && echo "HUGO_VERSION=$(sed -n 's/^ *hugo_version: *//p' >$GITHUB_ENV echo "PAGEFIND_VERSION=$(sed -n 's/^ *pagefind_version: *//p' >$GITHUB_ENV + echo "BASE_URL=${{ steps.pages.outputs.base_url }}" >>$GITHUB_ENV - name: install Hugo ${{ env.HUGO_VERSION }} shell: bash @@ -59,7 +60,7 @@ runs: env: HUGO_RELATIVEURLS: false shell: bash - run: hugo config && hugo --baseURL "${{ steps.pages.outputs.base_url }}/" + run: hugo config && hugo --baseURL "$BASE_URL/" - name: run Pagefind ${{ env.PAGEFIND_VERSION }} to build the search index shell: bash @@ -110,13 +111,12 @@ runs: id: remap shell: bash run: | - base_url='${{ steps.pages.outputs.base_url }}' - echo "result=$(echo "$base_url" | + echo "result=$(echo "$BASE_URL" | sed 's|^\(.*\)\(/git-scm\.com\)$|(\1)?\2(.*)|') file://$PWD/public\$2" \ >>$GITHUB_OUTPUT # When running in forks, do detect when links try to break out of the # `/git-scm.com/` subdirectory - echo "remap-dotdot=$(echo "$base_url" | + echo "remap-dotdot=$(echo "$BASE_URL" | sed -n 's|^\(https\?:\/\/.*\)\(/git-scm\.com\)$|--remap '\''(\1.*) file://../$1'\''|p')" \ >>$GITHUB_OUTPUT @@ -127,7 +127,7 @@ runs: args: >- --offline --fallback-extensions html - --base '${{ steps.pages.outputs.base_url }}' + --base '$BASE_URL' --remap '${{ steps.remap.outputs.result }}' ${{ steps.remap.outputs.remap-dotdot }} --exclude file:///path/to/repo.git/ @@ -199,9 +199,8 @@ runs: - name: Run Playwright tests shell: bash id: playwright - env: - PLAYWRIGHT_TEST_URL: ${{ steps.pages.outputs.base_url }} run: | + PLAYWRIGHT_TEST_URL="$BASE_URL" # avoid test failures when HTTPS is enforced half-way through case "$PLAYWRIGHT_TEST_URL" in https://*|http://git-scm.com) ;; # okay, leave as-is From 2b4aea9eccd2de7cd3ce1bfef8dc90875642fb0f Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 26 Feb 2025 08:15:31 +0100 Subject: [PATCH 2/2] deploy: work around the grayed out "Enforce HTTPS" checkbox We do want to enforce HTTPS. And we kind of do, but not "kind of" enough for GitHub's UI at https://github.com/git/git-scm.com/settings/pages to allow us to check the box called "Enforce HTTPS". The helpful comment next to the grayed out box says: [ ] **Enforce HTTPS** --- Unavailable for your site because your domain is not properly configured to support HTTPS ([`git-scm.com`](http://git-scm.com/)) --- [Troubleshooting custom domains](https://docs.github.com/articles/troubleshooting-custom-domains/#https-errors) HTTPS provides a layer of encryption that prevents others from snooping on or tampering with traffic to your site. When HTTPS is enforced, your site will only be served over HTTPS. [Learn more about securing your GitHub Pages site with HTTPS](https://docs.github.com/pages/getting-started-with-github-pages/securing-your-github-pages-site-with-https). As discussed in https://github.com/git/git-scm.com/pull/1953, it would appear to be outside our capabilities to fix this properly, therefore we are unfortunately stuck with hard-coding a work-around: Manually override the http:// URL produced by `actions/configure-pages` with the equivalent https:// one. Signed-off-by: Johannes Schindelin --- .github/actions/deploy-to-github-pages/action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/actions/deploy-to-github-pages/action.yml b/.github/actions/deploy-to-github-pages/action.yml index ac0d01424d..48a72cade7 100644 --- a/.github/actions/deploy-to-github-pages/action.yml +++ b/.github/actions/deploy-to-github-pages/action.yml @@ -47,7 +47,9 @@ runs: set -x && echo "HUGO_VERSION=$(sed -n 's/^ *hugo_version: *//p' >$GITHUB_ENV echo "PAGEFIND_VERSION=$(sed -n 's/^ *pagefind_version: *//p' >$GITHUB_ENV - echo "BASE_URL=${{ steps.pages.outputs.base_url }}" >>$GITHUB_ENV + BASE_URL=${{ steps.pages.outputs.base_url }} + test http://git-scm.com != "$BASE_URL" || BASE_URL="https://${BASE_URL#http://}" + echo "BASE_URL=$BASE_URL" >>$GITHUB_ENV - name: install Hugo ${{ env.HUGO_VERSION }} shell: bash