Skip to content

Commit cb4696d

Browse files
committed
deploy: copy back a couple files to help transitioning away from Rails
Currently, Git's home page is still a Rails app. When we tried to transition away from it to the new Hugo/Pagefind-backed site, we noticed a couple of problems, where some pages would look quite odd. The reason turned out to be both Cloudflare and browser caching, where force-reloading some pages would still retrieve the original versions of the pages, but the `.css` and `.js` files referenced by those original versions were gone. And it is not just because the Hugo site puts those files in different locations: Rails automatically amends the file name of style sheets and Javascript libraries with a hash so that stale caches would not play a role when new versions of those files become available (historically, browsers are quite challenged when it comes to force-reloading pages where also their referenced `.css`/`.js` files need to be force-reloaded). We can help with that! Simply by "putting back" those `.css`/`.js` files into the place where the Rails version of the pages expects them. Luckily, those files haven't changed very much, the most recent one was the September update to disallow font ligatures in code blocks, and the second-most recent was the August update to add the `/` keyboard shortcut to get to the search box. Here are the `Last-modified:` headers of those files when fetching them from https://git-scm.com/: application*.css: Tue, 10 Sep 2024 17:26:19 GMT application*.js: Mon, 19 Aug 2024 07:40:42 GMT modernize*.js: Tue, 15 Dec 2020 06:13:03 GMT So those files are very unlikely to change a lot, especially now, during the transition. By adding them to the Hugo/Pagefind site, even partial caches should not break the site when switching DNS over to GitHub Pages. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent b1986a3 commit cb4696d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

.github/actions/deploy-to-github-pages/action.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,25 @@ runs:
5959
shell: bash
6060
run: npx -y pagefind@${{ env.PAGEFIND_VERSION }} --site public
6161

62+
- name: Temporarily copy some Rails assets to help the transition
63+
shell: bash
64+
run: |
65+
# To help with the transition from the Rails app to the Hugo/Pagefind site, where
66+
# at least for a while the cached version of git-scm.com might be served via
67+
# Cloudflare, according to the first transition attempt on Sep 20, 2024, potentially
68+
# partially, i.e. _some_ assets might still be cached, _some_ others might not, let's
69+
# copy the most prominent assets to the new page so that, say, the original front page
70+
# won't fail to load the style sheet and Javascript libraries that it needs.
71+
set -x &&
72+
mkdir -p public/assets &&
73+
for f in application-93865c5c820c24f4c599e8b9c544bcd8a0d03260f9b16c9ba80b6a00082112c9.css \
74+
application-f7a750114a26afea236a5cc26f6ff3925a14c5901e9ea9018fb869432d0cbee3.js \
75+
modernize-b3ebe0c31c24f230dc62179d3e1030d2e57a53b1668d9382c0a27dbd44a94beb.js
76+
do
77+
curl -Lfo public/assets/$f https://git-scm.com/assets/$f ||
78+
echo "::error::could not copy $f from https://git-scm.com/" >&2
79+
done
80+
6281
- name: upload GitHub Pages artifact
6382
uses: actions/upload-pages-artifact@v3
6483
with:

0 commit comments

Comments
 (0)