diff --git a/ci/setup_spack.sh b/ci/setup_spack.sh
index e08654e05fea312ee10985c39802dec51af18d7c..1a18fbaba79b753f995c9e6a12be8123c1b91819 100755
--- a/ci/setup_spack.sh
+++ b/ci/setup_spack.sh
@@ -46,6 +46,11 @@ echo "Setting up buildcache"
 spack/bin/spack gpg trust \
     $GPG_PRIVATE_KEY
 
+spack/bin/spack mirror add \
+    --type binary \
+    --scope system \
+    buildcache file:///buildcache
+
 if [ ! -d /buildcache/build_cache ]; then
   spack/bin/spack gpg publish \
       -d /buildcache
@@ -56,8 +61,3 @@ spack/bin/spack buildcache keys \
     --trust
 
 spack/bin/spack buildcache update-index /buildcache
-
-spack/bin/spack mirror add \
-    --type binary \
-    --scope system \
-    buildcache file:///buildcache