fix for potential time delay?

This commit is contained in:
Clement Tsang
2025-12-25 19:08:45 -05:00
parent 54421171aa
commit c71e8f4776
3 changed files with 32 additions and 8 deletions
+8
View File
@@ -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
+7 -1
View File
@@ -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
secrets: inherit
with:
nightly: ${{needs.job1.outputs.output1}}
+17 -7
View File
@@ -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}")