From c71e8f477644d0523cb583cd8b969e5d42e2b28f Mon Sep 17 00:00:00 2001 From: Clement Tsang <34804052+ClementTsang@users.noreply.github.com> Date: Thu, 25 Dec 2025 19:08:45 -0500 Subject: [PATCH] fix for potential time delay? --- .github/workflows/docs.yml | 8 ++++++++ .github/workflows/nightly.yml | 8 +++++++- docs/hooks/nightly_redirect.py | 24 +++++++++++++++++------- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 9f44d52d..caaccca1 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -5,6 +5,12 @@ name: docs on: workflow_dispatch: workflow_call: + inputs: + nightly: + description: "Optional nightly redirect override" + default: "" + required: false + type: string push: branches: - main @@ -38,6 +44,8 @@ jobs: run: ./scripts/ci/configure_git.sh - name: Build and deploy docs with mike + env: + MKDOCS_NIGHTLY_RELEASE_OVERRIDE: ${{ inputs.nightly || '' }} run: | cd docs mike deploy nightly --push diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 1dae1507..f2d71d49 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -56,6 +56,8 @@ jobs: name: upload-release needs: build-release runs-on: ubuntu-latest + outputs: + TAG_NAME: ${{ steps.tag_release_name.outputs.TAG_NAME }} steps: - name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 @@ -94,11 +96,13 @@ jobs: - name: Create and set tag name and release name if: github.event.inputs.isMock != 'true' + id: tag_release_name run: | COMMIT_HASH=$(git rev-parse --short=8 HEAD) TIME=$(date +%s) TAG_NAME=$(echo "nightly-$COMMIT_HASH-$TIME") echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV + echo "TAG_NAME=$$TAG_NAME" >> "$GITHUB_OUTPUT" echo "$TAG_NAME" DATE=$(date '+%Y-%m-%d') @@ -130,4 +134,6 @@ jobs: needs: [initialize-job, upload-release] if: ${{ needs.initialize-job.outputs.should_skip != 'true' && github.event.inputs.isMock != 'true' }} uses: ./.github/workflows/docs.yml - secrets: inherit \ No newline at end of file + secrets: inherit + with: + nightly: ${{needs.job1.outputs.output1}} diff --git a/docs/hooks/nightly_redirect.py b/docs/hooks/nightly_redirect.py index 1e5140b6..31ad6f41 100644 --- a/docs/hooks/nightly_redirect.py +++ b/docs/hooks/nightly_redirect.py @@ -1,3 +1,4 @@ +import os import mkdocs.plugins import urllib.request import json @@ -9,19 +10,28 @@ import json def on_config(config): print("Running nightly release redirect hook...") try: - with urllib.request.urlopen("https://api.github.com/repos/ClementTsang/bottom/releases") as response: - raw_data = response.read() - data = json.loads(raw_data.decode('utf-8')) + nightly_tag_name = None + override = os.environ.get('MKDOCS_NIGHTLY_RELEASE_OVERRIDE') - first_nightly = next(release for release in data if "nightly-" in release["tag_name"]) - nightly_tag_name = first_nightly["tag_name"] + if override: + nightly_tag_name = override + else: + with urllib.request.urlopen("https://api.github.com/repos/ClementTsang/bottom/releases") as response: + raw_data = response.read() + data = json.loads(raw_data.decode('utf-8')) - redirect_plugin = config.get('plugins', {}).get('redirects') - redirects = redirect_plugin.config.get('redirect_maps', {}) + first_nightly = next(release for release in data if "nightly-" in release["tag_name"]) + nightly_tag_name = first_nightly["tag_name"] + redirect_plugin = config.get('plugins', {}).get('redirects') + redirects = redirect_plugin.config.get('redirect_maps', {}) + + if nightly_tag_name is not None: nightly_release_url = f"https://github.com/ClementTsang/bottom/releases/tag/{nightly_tag_name}" print(f"Updated nightly release redirect to point to {nightly_release_url}") redirects["nightly-release.md"] = nightly_release_url + else: + print("nightly tag name was not set by any means.") except Exception as e: print(f"error adjusting redirect, falling back to general releases page: {e}")