@@ -30,7 +30,16 @@ def end_of_job(dist: Path, always_continue: bool):
3030 shutil .rmtree (str (dist ))
3131
3232
33- def main (always_continue : bool = True , skip_update_external : bool = True ):
33+ def main (always_continue : bool = True , skip_update_external : bool = False , with_state : bool = False ):
34+ """ run a close equivalent to the 'update collection' (auto_update_main.yaml) workflow.
35+ # todo: improve this script and substitute the GitHub Actions CI with it in order to make deployment more transparent
36+
37+ Args:
38+ always_continue: Set to False for debugging to pause between individual deployment steps
39+ skip_update_external: Don't query zenodo.org for new relevant records
40+ with_state: checkout current 'gh-pages' branch and 'lst_ci_run" tag to evaluate difference only
41+
42+ """
3443 # local setup
3544 collection = Path (__file__ ).parent / "../collection"
3645
@@ -44,13 +53,21 @@ def main(always_continue: bool = True, skip_update_external: bool = True):
4453
4554 gh_pages = Path (__file__ ).parent / "../gh-pages"
4655 if not gh_pages .exists ():
47- subprocess .run (["git" , "worktree" , "prune" ], check = True )
48- subprocess .run (["git" , "worktree" , "add" , "--detach" , str (gh_pages ), "gh-pages" ], check = True )
56+ if with_state :
57+ subprocess .run (["git" , "worktree" , "prune" ], check = True )
58+ subprocess .run (["git" , "worktree" , "add" , "--detach" , str (gh_pages ), "gh-pages" ], check = True )
59+ else :
60+ gh_pages .mkdir ()
4961
5062 last_collection = Path (__file__ ).parent / "../last_ci_run/collection"
5163 if not last_collection .parent .exists ():
52- subprocess .run (["git" , "worktree" , "prune" ], check = True )
53- subprocess .run (["git" , "worktree" , "add" , "--detach" , str (last_collection .parent ), "last_ci_run" ], check = True )
64+ if with_state :
65+ subprocess .run (["git" , "worktree" , "prune" ], check = True )
66+ subprocess .run (
67+ ["git" , "worktree" , "add" , "--detach" , str (last_collection .parent ), "last_ci_run" ], check = True
68+ )
69+ else :
70+ last_collection .mkdir (parents = True )
5471
5572 dist = Path (__file__ ).parent / "../dist"
5673 if dist .exists ():
@@ -137,6 +154,10 @@ def main(always_continue: bool = True, skip_update_external: bool = True):
137154
138155 end_of_job (dist , always_continue )
139156
157+ # copy _header and index.html file in order to enable a valid bioimage.io preview
158+ shutil .copy ("_headers" , str (gh_pages / "_headers" ))
159+ shutil .copy ("index.html" , str (gh_pages / "index.html" ))
160+
140161
141162if __name__ == "__main__" :
142163 typer .run (main )
0 commit comments