mirror of
https://github.com/ClementTsang/bottom.git
synced 2026-05-29 18:20:57 +00:00
fix for potential time delay?
This commit is contained in:
@@ -5,6 +5,12 @@ name: docs
|
|||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
nightly:
|
||||||
|
description: "Optional nightly redirect override"
|
||||||
|
default: ""
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
@@ -38,6 +44,8 @@ jobs:
|
|||||||
run: ./scripts/ci/configure_git.sh
|
run: ./scripts/ci/configure_git.sh
|
||||||
|
|
||||||
- name: Build and deploy docs with mike
|
- name: Build and deploy docs with mike
|
||||||
|
env:
|
||||||
|
MKDOCS_NIGHTLY_RELEASE_OVERRIDE: ${{ inputs.nightly || '' }}
|
||||||
run: |
|
run: |
|
||||||
cd docs
|
cd docs
|
||||||
mike deploy nightly --push
|
mike deploy nightly --push
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ jobs:
|
|||||||
name: upload-release
|
name: upload-release
|
||||||
needs: build-release
|
needs: build-release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
TAG_NAME: ${{ steps.tag_release_name.outputs.TAG_NAME }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
|
||||||
@@ -94,11 +96,13 @@ jobs:
|
|||||||
|
|
||||||
- name: Create and set tag name and release name
|
- name: Create and set tag name and release name
|
||||||
if: github.event.inputs.isMock != 'true'
|
if: github.event.inputs.isMock != 'true'
|
||||||
|
id: tag_release_name
|
||||||
run: |
|
run: |
|
||||||
COMMIT_HASH=$(git rev-parse --short=8 HEAD)
|
COMMIT_HASH=$(git rev-parse --short=8 HEAD)
|
||||||
TIME=$(date +%s)
|
TIME=$(date +%s)
|
||||||
TAG_NAME=$(echo "nightly-$COMMIT_HASH-$TIME")
|
TAG_NAME=$(echo "nightly-$COMMIT_HASH-$TIME")
|
||||||
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
|
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
|
||||||
|
echo "TAG_NAME=$$TAG_NAME" >> "$GITHUB_OUTPUT"
|
||||||
echo "$TAG_NAME"
|
echo "$TAG_NAME"
|
||||||
|
|
||||||
DATE=$(date '+%Y-%m-%d')
|
DATE=$(date '+%Y-%m-%d')
|
||||||
@@ -130,4 +134,6 @@ jobs:
|
|||||||
needs: [initialize-job, upload-release]
|
needs: [initialize-job, upload-release]
|
||||||
if: ${{ needs.initialize-job.outputs.should_skip != 'true' && github.event.inputs.isMock != 'true' }}
|
if: ${{ needs.initialize-job.outputs.should_skip != 'true' && github.event.inputs.isMock != 'true' }}
|
||||||
uses: ./.github/workflows/docs.yml
|
uses: ./.github/workflows/docs.yml
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
with:
|
||||||
|
nightly: ${{needs.job1.outputs.output1}}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
import mkdocs.plugins
|
import mkdocs.plugins
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import json
|
import json
|
||||||
@@ -9,19 +10,28 @@ import json
|
|||||||
def on_config(config):
|
def on_config(config):
|
||||||
print("Running nightly release redirect hook...")
|
print("Running nightly release redirect hook...")
|
||||||
try:
|
try:
|
||||||
with urllib.request.urlopen("https://api.github.com/repos/ClementTsang/bottom/releases") as response:
|
nightly_tag_name = None
|
||||||
raw_data = response.read()
|
override = os.environ.get('MKDOCS_NIGHTLY_RELEASE_OVERRIDE')
|
||||||
data = json.loads(raw_data.decode('utf-8'))
|
|
||||||
|
|
||||||
first_nightly = next(release for release in data if "nightly-" in release["tag_name"])
|
if override:
|
||||||
nightly_tag_name = first_nightly["tag_name"]
|
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')
|
first_nightly = next(release for release in data if "nightly-" in release["tag_name"])
|
||||||
redirects = redirect_plugin.config.get('redirect_maps', {})
|
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}"
|
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}")
|
print(f"Updated nightly release redirect to point to {nightly_release_url}")
|
||||||
redirects["nightly-release.md"] = 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:
|
except Exception as e:
|
||||||
print(f"error adjusting redirect, falling back to general releases page: {e}")
|
print(f"error adjusting redirect, falling back to general releases page: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user