From 0b279256dcb02ced81978914d7f7ba037fdd8e6c Mon Sep 17 00:00:00 2001 From: Chris Coley <chris@codingallnight.com> Date: Sat, 15 Jun 2024 19:55:53 -0700 Subject: [PATCH] Include all URLs for a page when purging the cache --- .gitlab-ci.yml | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index beb9629..09addc1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -80,10 +80,30 @@ create-purge-json: tags: - docker script: - - >- - echo -en "{\n \"files\": [\n \"$CI_PAGES_URL/\"" > purge.json; - for d in $(find public/* -type d); do echo -en ",\n \"$CI_PAGES_URL/${d#public/}/\"" >> purge.json; done; - for f in $(find public -type f); do echo -en ",\n \"$CI_PAGES_URL/${f#public/}\"" >> purge.json; done; + - |- + echo -en "{\n \"files\": [" > purge.json + # Add the index-less homepage, with and without trailing slash + echo -en "\n \"$CI_PAGES_URL\"" >> purge.json + echo -en ",\n \"$CI_PAGES_URL/\"" >> purge.json + # Add all the directories, with and without trailing slash + for d in $(find public/* -type d); do + echo -en ",\n \"$CI_PAGES_URL/${d#public/}\"" >> purge.json + echo -en ",\n \"$CI_PAGES_URL/${d#public/}/\"" >> purge.json + done + # Add all the non-HTML files, with and without trailing slash + for f in $(find public -type f -not -iname '*.html'); do + echo -en ",\n \"$CI_PAGES_URL/${f#public/}\"" >> purge.json + echo -en ",\n \"$CI_PAGES_URL/${f#public/}/\"" >> purge.json + done + # Add all the HTML files, with and without trailing slash. First with file + # extension, then without + for f in $(find public -type f -iname '*.html'); do + echo -en ",\n \"$CI_PAGES_URL/${f#public/}\"" >> purge.json + echo -en ",\n \"$CI_PAGES_URL/${f#public/}/\"" >> purge.json + f="${f%.html}" + echo -en ",\n \"$CI_PAGES_URL/${f#public/}\"" >> purge.json + echo -en ",\n \"$CI_PAGES_URL/${f#public/}/\"" >> purge.json + done echo -e "\n ]\n}" >> purge.json - cat purge.json artifacts: -- GitLab