Skip to content

deploy: napari/docs@7e057fcd8d25d4f941f372c359a0a5e8289aec5c #671

deploy: napari/docs@7e057fcd8d25d4f941f372c359a0a5e8289aec5c

deploy: napari/docs@7e057fcd8d25d4f941f372c359a0a5e8289aec5c #671

name: Copy unversioned pages
# Unversioned pages are pages with general content that shouldn't change from
# version to version. Examples: community, developers, naps, release, roadmaps
# See https://napari.org/stable/developers/contributing/documentation/docs_deployment.html#documentation-and-website-deployment
on:
push:
branches:
- gh-pages
page_build:
workflow_dispatch:
jobs:
copy-pages:
name: Copy unversioned pages
runs-on: ubuntu-latest
permissions:
contents: write
pages: write
steps:
- name: Clone artifacts repo
uses: actions/checkout@v4
with:
ref: "gh-pages"
- name: Copy pages
run: |
ls -la
echo "Unversioned folders: community, developers, naps, release, roadmaps"
echo "Remove existing `stable` unversioned folders and"
echo "copy `dev` unversioned folders to `stable`"
rm -rf ./stable/community
cp -Rv ./dev/community/ ./stable/
rm -rf ./stable/developers
cp -Rv ./dev/developers/ ./stable/
rm -rf ./stable/naps
cp -Rv ./dev/naps/ ./stable/
rm -rf ./stable/release
cp -Rv ./dev/release/ ./stable/
rm -rf ./stable/roadmaps
cp -Rv ./dev/roadmaps/ ./stable/
echo "Copy dev/index.html to stable folder"
cp -v ./dev/index.html ./stable/
echo "In stable unversioned folder, find all regular files;"
echo "If /_static is in file, substitute /../dev/_static by editing in place."
# Don't touch the line containing DOCUMENTATION_OPTIONS.theme_switcher_json_url"
find stable/community/ -type f -exec sed -i '/DOCUMENTATION_OPTIONS.theme_switcher_json_url/!s+/_static+/../dev/_static+g' {} +
find stable/developers/ -type f -exec sed -i '/DOCUMENTATION_OPTIONS.theme_switcher_json_url/!s+/_static+/../dev/_static+g' {} +
find stable/naps/ -type f -exec sed -i '/DOCUMENTATION_OPTIONS.theme_switcher_json_url/!s+/_static+/../dev/_static+g' {} +
find stable/release/ -type f -exec sed -i '/DOCUMENTATION_OPTIONS.theme_switcher_json_url/!s+/_static+/../dev/_static+g' {} +
find stable/roadmaps/ -type f -exec sed -i '/DOCUMENTATION_OPTIONS.theme_switcher_json_url/!s+/_static+/../dev/_static+g' {} +
echo "Find _static and replace with ../dev/_static in the stable/index.html file."
sed -i '/DOCUMENTATION_OPTIONS.theme_switcher_json_url/!s+/_static+/../dev/_static+g' stable/index.html
echo "Set STABLE environmment variable to the version found in the symlinked stable directory"
STABLE=$(basename $(readlink -f ./stable))
echo "Updates the theme switcher version from 'dev' to stable numeric version (e.g. '0.6.3') in all files of the stable directory."
find stable/ -type f -exec sed -i "s+DOCUMENTATION_OPTIONS.theme_switcher_version_match = 'dev';+DOCUMENTATION_OPTIONS.theme_switcher_version_match = '${STABLE}';+g" {} +
echo "The version warning banner should be on for all versions except stable."
echo "TODO: Make this automatic for all future versions i.e. revert this change whenever a new version is released."
find stable/ -type f -exec sed -i "s+DOCUMENTATION_OPTIONS.show_version_warning_banner = true;+DOCUMENTATION_OPTIONS.show_version_warning_banner = false;+g" {} +
- name: Commit files
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .
git commit -m "Copy unversioned files" --allow-empty
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages