diff --git a/.github/mkdocs/mkdocs.yaml b/.github/mkdocs/mkdocs.yaml index 5117f6d4..677bfae0 100644 --- a/.github/mkdocs/mkdocs.yaml +++ b/.github/mkdocs/mkdocs.yaml @@ -1,5 +1,9 @@ site_name: SciCatLive docs_dir: ../../docs +repo_url: !!python/object/apply:os.path.join [ + !ENV [GITHUB_SERVER_URL], + !ENV [GITHUB_REPOSITORY] +] theme: name: material custom_dir: overrides diff --git a/.github/mkdocs/relative_to.py b/.github/mkdocs/relative_to.py index a0ec2aab..b3404943 100644 --- a/.github/mkdocs/relative_to.py +++ b/.github/mkdocs/relative_to.py @@ -16,5 +16,5 @@ def on_page_content(html, page, config, files): resolved_path = Path(ospath.normpath(page_path / path)) if any(filter(lambda x: Path(x.src_uri.strip('README.md')) == resolved_path, docs)): # Exiting docs continue - element['href'] = urljoin(f"{environ['BASE_URL']}/", ospath.normpath(page_path / element['href'])) + element['href'] = urljoin(f"{config.repo_url}/blob/{environ.get('TAG', 'main')}/", ospath.normpath(page_path / element['href'])) return soup.prettify() diff --git a/.github/workflows/mkdocs.yaml b/.github/workflows/mkdocs.yaml index 63179a39..054bef93 100644 --- a/.github/workflows/mkdocs.yaml +++ b/.github/workflows/mkdocs.yaml @@ -32,12 +32,10 @@ jobs: - name: Deploy documentation run: | if [[ "${{ github.ref_type }}" == "tag" ]]; then - TAG=${{ github.ref_name }} + export TAG=${{ github.ref_name }} VERSION=$(echo ${TAG} | awk -F'.' '{print $1"."$2}') fi - export BASE_URL=${BASE_URL}/${TAG:-main} - git fetch origin ${DOCS_BRANCH} --depth=1 mike deploy -F ${DOCS_CONFIG} \ --push --branch ${DOCS_BRANCH} \ @@ -48,6 +46,5 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GIT_COMMITTER_NAME: ci-bot GIT_COMMITTER_EMAIL: ci-bot@example.com - BASE_URL: https://github.com/SciCatProject/scicatlive/blob DOCS_BRANCH: gh-pages DOCS_CONFIG: .github/mkdocs/mkdocs.yaml