Split Docs action into separate workflow (#15656)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
pull/15668/head
Glenn Jocher 3 months ago committed by GitHub
parent a6f4a9f2d4
commit 72032fb114
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 50
      .github/workflows/ci.yaml
  2. 81
      .github/workflows/docs.yml
  3. 27
      .github/workflows/publish.yml

@ -38,56 +38,6 @@ on:
type: boolean type: boolean
jobs: jobs:
Docs:
# TODO: break this job out into it's own action with pull_request_target to allow changes to user forks
if: github.repository == 'ultralytics/ultralytics'
runs-on: macos-14
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.head_ref || github.ref }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
cache: "pip" # caching pip dependencies
- name: Install Dependencies
run: pip install tqdm mkdocs-material "mkdocstrings[python]" mkdocs-jupyter mkdocs-redirects mkdocs-ultralytics-plugin mkdocs-macros-plugin
- name: Update Docs Reference Section
run: python docs/build_reference.py
- name: Commit and Push Reference Section Changes
run: |
git pull origin ${{ github.head_ref || github.ref }}
git add .
git reset HEAD -- .github/workflows/ # workflow changes are not permitted with default token
git config --global user.name "UltralyticsAssistant"
git config --global user.email "web@ultralytics.com"
if ! git diff --staged --quiet; then
git commit -m "Auto-update Ultralytics Docs Reference Section by https://ultralytics.com/actions"
git push
else
echo "No changes to commit"
fi
- name: Build Docs and Check for Warnings
run: python docs/build_docs.py
- name: Commit and Push Docs changes
continue-on-error: true
if: always() && github.event_name == 'pull_request'
run: |
git pull origin ${{ github.head_ref || github.ref }}
git add --update # only add updated files
git reset HEAD -- .github/workflows/ # workflow changes are not permitted with default token
if ! git diff --staged --quiet; then
git commit -m "Auto-update Ultralytics Docs by https://ultralytics.com/actions"
git push
else
echo "No changes to commit"
fi
HUB: HUB:
if: github.repository == 'ultralytics/ultralytics' && (github.event_name == 'schedule' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.hub == 'true')) if: github.repository == 'ultralytics/ultralytics' && (github.event_name == 'schedule' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.hub == 'true'))
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}

@ -0,0 +1,81 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license
# Test and publish docs to https://docs.ultralytics.com
name: Publish Docs
on:
push:
branches: [main]
pull_request_target:
branches: [main]
workflow_dispatch:
jobs:
Docs:
if: github.repository == 'ultralytics/ultralytics'
runs-on: macos-14
steps:
- name: Git config
run: |
git config --global user.name "UltralyticsAssistant"
git config --global user.email "web@ultralytics.com"
- name: Checkout Repository
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request_target.head.repo.full_name || github.repository }}
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.head_ref || github.ref }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
cache: "pip" # caching pip dependencies
- name: Install Dependencies
run: pip install black tqdm mkdocs-material "mkdocstrings[python]" mkdocs-jupyter mkdocs-redirects mkdocs-ultralytics-plugin mkdocs-macros-plugin
- name: Update Docs Reference Section and Push Changes
if: github.event_name == 'pull_request_target'
run: |
python docs/build_reference.py
git pull origin ${{ github.head_ref || github.ref }}
git add .
git reset HEAD -- .github/workflows/ # workflow changes are not permitted with default token
if ! git diff --staged --quiet; then
git commit -m "Auto-update Ultralytics Docs Reference Section by https://ultralytics.com/actions"
git push
else
echo "No changes to commit"
fi
- name: Build Docs and Check for Warnings
run: |
export JUPYTER_PLATFORM_DIRS=1
python docs/build_docs.py
- name: Commit and Push Docs changes
continue-on-error: true
if: always() && github.event_name == 'pull_request_target'
run: |
git pull origin ${{ github.head_ref || github.ref }}
git add --update # only add updated files
git reset HEAD -- .github/workflows/ # workflow changes are not permitted with default token
if ! git diff --staged --quiet; then
git commit -m "Auto-update Ultralytics Docs by https://ultralytics.com/actions"
git push
else
echo "No changes to commit"
fi
- name: Publish Docs to https://docs.ultralytics.com
if: github.event_name == 'push'
env:
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
INDEXNOW_KEY: ${{ secrets.INDEXNOW_KEY_DOCS }}
run: |
git clone https://github.com/ultralytics/docs.git docs-repo
cd docs-repo
git checkout gh-pages || git checkout -b gh-pages
rm -rf *
cp -R ../site/* .
echo "$INDEXNOW_KEY" > "$INDEXNOW_KEY.txt"
git add .
LATEST_HASH=$(git rev-parse --short=7 HEAD)
git commit -m "Update Docs for 'ultralytics ${{ steps.check_pypi.outputs.version }} - $LATEST_HASH'"
git push https://$PERSONAL_ACCESS_TOKEN@github.com/ultralytics/docs.git gh-pages

@ -1,7 +1,7 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license # Ultralytics YOLO 🚀, AGPL-3.0 license
# Publish pip package to PyPI https://pypi.org/project/ultralytics/ and Docs to https://docs.ultralytics.com # Publish pip package to PyPI https://pypi.org/project/ultralytics/
name: Publish to PyPI and Deploy Docs name: Publish to PyPI
on: on:
push: push:
@ -11,9 +11,6 @@ on:
pypi: pypi:
type: boolean type: boolean
description: Publish to PyPI description: Publish to PyPI
docs:
type: boolean
description: Deploy Docs
jobs: jobs:
publish: publish:
@ -161,26 +158,6 @@ jobs:
run: | run: |
python -m build python -m build
python -m twine upload dist/* -u __token__ -p $PYPI_TOKEN python -m twine upload dist/* -u __token__ -p $PYPI_TOKEN
- name: Deploy Docs
continue-on-error: true
if: (github.event_name == 'push' || github.event.inputs.docs == 'true') && github.repository == 'ultralytics/ultralytics' && github.actor == 'glenn-jocher'
env:
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
INDEXNOW_KEY: ${{ secrets.INDEXNOW_KEY_DOCS }}
run: |
pip install black
export JUPYTER_PLATFORM_DIRS=1
python docs/build_docs.py
git clone https://github.com/ultralytics/docs.git docs-repo
cd docs-repo
git checkout gh-pages || git checkout -b gh-pages
rm -rf *
cp -R ../site/* .
echo "$INDEXNOW_KEY" > "$INDEXNOW_KEY.txt"
git add .
LATEST_HASH=$(git rev-parse --short=7 HEAD)
git commit -m "Update Docs for 'ultralytics ${{ steps.check_pypi.outputs.version }} - $LATEST_HASH'"
git push https://$PERSONAL_ACCESS_TOKEN@github.com/ultralytics/docs.git gh-pages
- name: Extract PR Details - name: Extract PR Details
run: | run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then if [ "${{ github.event_name }}" = "pull_request" ]; then

Loading…
Cancel
Save