diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d69b95cb..0af29d29 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -38,56 +38,6 @@ on: type: boolean 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: 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 }} diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..1545674c --- /dev/null +++ b/.github/workflows/docs.yml @@ -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 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3c0c2550..c2b9c5c8 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,7 +1,7 @@ # 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: push: @@ -11,9 +11,6 @@ on: pypi: type: boolean description: Publish to PyPI - docs: - type: boolean - description: Deploy Docs jobs: publish: @@ -161,26 +158,6 @@ jobs: run: | python -m build 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 run: | if [ "${{ github.event_name }}" = "pull_request" ]; then