From 68b584b77c38ee19677cb8b385523838c787153d Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Thu, 4 Jun 2026 03:24:29 +0800 Subject: [PATCH] Improve Actions docs and comment accuracy (#755) --- .github/workflows/scan-prs.yml | 2 +- README.md | 13 ++++++++----- action.yml | 3 ++- actions/__init__.py | 3 ++- actions/first_interaction.py | 2 +- actions/scan_prs.py | 2 +- actions/summarize_pr.py | 2 +- actions/summarize_release.py | 2 +- actions/update_markdown_code_blocks.py | 2 +- actions/utils/openai_utils.py | 2 +- dependabot/README.md | 2 +- dependabot/action.yml | 2 +- scan-prs/README.md | 18 ++++++++++-------- scan-prs/action.yml | 2 +- 14 files changed, 32 insertions(+), 25 deletions(-) diff --git a/.github/workflows/scan-prs.yml b/.github/workflows/scan-prs.yml index 2431817..11c0f57 100644 --- a/.github/workflows/scan-prs.yml +++ b/.github/workflows/scan-prs.yml @@ -1,6 +1,6 @@ # Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license -# List Open PRs across Ultralytics repositories and auto-merge eligible Dependabot PRs +# List Open PRs across Ultralytics repositories and auto-merge eligible GitHub Actions update PRs name: Scan PRs diff --git a/README.md b/README.md index 0aa9431..d0bb092 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ AI-powered formatting, labeling, and PR summaries for Python, Swift, and Markdow - **Broken Links Check:** Broken links identified using [Lychee](https://github.com/lycheeverse/lychee) - **PR Summary:** Concise Pull Request summaries generated using AI - **PR Review:** AI-powered code reviews identify critical bugs, security issues, and quality concerns with suggested fixes -- **Auto-labeling:** Applies relevant labels to issues and PRs via AI +- **Auto-labeling:** Applies relevant labels to issues, PRs, and discussions via AI ### 🤖 Supported AI Providers @@ -55,9 +55,9 @@ The model is auto-detected based on which API key you provide. Override with the Triggers on GitHub events to streamline workflows: -- **Push Events:** Automatically formats code when changes are pushed to `main` - **Pull Requests:** Ensures formatting standards, generates summaries, provides AI reviews, and applies labels - **Issues:** Automatically applies relevant labels using AI +- **Discussions:** Automatically applies relevant labels using AI ### 🔧 Setup @@ -74,6 +74,8 @@ name: Ultralytics Actions on: issues: types: [opened] + discussion: + types: [created] pull_request: branches: [main] types: [opened, closed, synchronize, review_requested] @@ -82,6 +84,7 @@ permissions: contents: write # Modify code in PRs pull-requests: write # Add comments and labels to PRs issues: write # Add comments and labels to issues + discussions: write # Add labels to discussions jobs: actions: @@ -93,7 +96,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} # Auto-generated token labels: true # Auto-label issues/PRs using AI python: true # Format Python with Ruff - python_docstrings: false # Format Python docstrings (default: false) + python_docstrings: true # Format Python docstrings (default: true) biome: true # Format JS/TS with Biome (auto-detected via biome.json) prettier: true # Format YAML, JSON, Markdown, CSS swift: false # Format Swift (requires macos-latest) @@ -139,7 +142,7 @@ Free up disk space on GitHub runners by removing unnecessary packages and files. ### 3. Scan PRs Action -List open PRs across an organization and auto-merge eligible Dependabot PRs. +List open PRs across an organization and auto-merge eligible GitHub Actions update PRs. ```yaml - uses: ultralytics/actions/scan-prs@main @@ -181,7 +184,7 @@ Ultralytics thrives on community collaboration, and we deeply value your contrib Ultralytics offers two licensing options: -- **AGPL-3.0 License**: An [OSI-approved](https://opensource.org/license/agpl-3.0) open-source license ideal for students, researchers, and enthusiasts who value open collaboration. See the [LICENSE](https://github.com/ultralytics/ultralytics/blob/main/LICENSE) file for details. +- **AGPL-3.0 License**: An [OSI-approved](https://opensource.org/license/agpl-3.0) open-source license ideal for students, researchers, and enthusiasts who value open collaboration. See the [LICENSE](https://github.com/ultralytics/actions/blob/main/LICENSE) file for details. - **Enterprise License**: Designed for commercial use, this license allows integrating Ultralytics software and AI models into commercial products without AGPL-3.0's open-source requirements. For enterprise solutions, contact [Ultralytics Licensing](https://www.ultralytics.com/license). ## 📫 Contact diff --git a/action.yml b/action.yml index 57871a4..894f040 100644 --- a/action.yml +++ b/action.yml @@ -113,7 +113,7 @@ runs: GITHUB_REF: ${{ github.ref }} run: | echo "::group::Install Dependencies" - # Install from git branch if testing in ultralytics/actions repo, otherwise from PyPI + # Install from current git branch if testing in ultralytics/actions repo, otherwise from GitHub main branch if [ "$GITHUB_REPOSITORY" = "ultralytics/actions" ]; then echo "Installing from git branch: $GITHUB_REF" packages="git+https://github.com/ultralytics/actions@${GITHUB_REF#refs/heads/}" @@ -375,6 +375,7 @@ runs: uses: lycheeverse/lychee-action@v2.8.0 with: # Check all markdown and html files in repo. Ignores the following status codes to reduce false positives: + # - 401(generic, "unauthorized") # - 403(OpenVINO, "forbidden") # - 429(Instagram, "too many requests") # - 500(Zenodo, "cached") diff --git a/actions/__init__.py b/actions/__init__.py index 5cb96bb..a9a8bc1 100644 --- a/actions/__init__.py +++ b/actions/__init__.py @@ -11,7 +11,8 @@ # │ │ ├── __init__.py # │ │ ├── github_utils.py # │ │ ├── openai_utils.py -# │ │ └── common_utils.py +# │ │ ├── common_utils.py +# │ │ └── version_utils.py # │ ├── dispatch_actions.py # │ ├── first_interaction.py # │ ├── review_pr.py diff --git a/actions/first_interaction.py b/actions/first_interaction.py index 9b17727..63551fb 100644 --- a/actions/first_interaction.py +++ b/actions/first_interaction.py @@ -64,7 +64,7 @@ def get_event_content(event) -> tuple[int, str, str, str, str, str, str]: def get_relevant_labels( issue_type: str, title: str, body: str, available_labels: dict, current_labels: list ) -> list[str]: - """Determines relevant labels for GitHub issues/discussions using OpenAI.""" + """Determines relevant labels for GitHub issues/discussions using AI.""" filtered_labels = filter_labels(available_labels, current_labels, is_pr=(issue_type == "pull request")) labels_str = "\n".join(f"- {name}: {description}" for name, description in filtered_labels.items()) diff --git a/actions/scan_prs.py b/actions/scan_prs.py index 47ec60b..440e4ad 100644 --- a/actions/scan_prs.py +++ b/actions/scan_prs.py @@ -69,7 +69,7 @@ def get_status_checks(rollup): def run(): - """List open PRs across organization and auto-merge eligible Dependabot PRs.""" + """List open PRs across organization and auto-merge eligible GitHub Actions update PRs.""" org = os.getenv("ORG", "ultralytics") visibility_list = parse_visibility(os.getenv("VISIBILITY", "public"), os.getenv("REPO_VISIBILITY", "public")) filter_config = get_repo_filter(visibility_list) diff --git a/actions/summarize_pr.py b/actions/summarize_pr.py index 796a8df..2a89765 100644 --- a/actions/summarize_pr.py +++ b/actions/summarize_pr.py @@ -75,7 +75,7 @@ def generate_issue_comment(pr_url, pr_summary, pr_credit, pr_title=""): def generate_pr_summary(repository, diff_text): - """Generates a concise, professional summary of a PR using OpenAI's API.""" + """Generates a concise, professional summary of a PR using the OpenAI or Anthropic API.""" prompt, is_large, skipped_files = get_pr_summary_prompt(repository, diff_text) messages = [ diff --git a/actions/summarize_release.py b/actions/summarize_release.py index 4ecb702..278154d 100644 --- a/actions/summarize_release.py +++ b/actions/summarize_release.py @@ -43,7 +43,7 @@ def get_prs_between_tags(event, previous_tag: str, latest_tag: str) -> list: prs = [] for pr_number in sorted(pr_numbers): # earliest to latest - time.sleep(1) # Rate limit: GitHub search API has strict limits + time.sleep(1) # Rate limit: space out GitHub REST API requests pr_url = f"{GITHUB_API_URL}/repos/{event.repository}/pulls/{pr_number}" pr_response = event.get(pr_url) if pr_response.status_code == 200: diff --git a/actions/update_markdown_code_blocks.py b/actions/update_markdown_code_blocks.py index 4a89cca..76d31aa 100644 --- a/actions/update_markdown_code_blocks.py +++ b/actions/update_markdown_code_blocks.py @@ -157,7 +157,7 @@ def generate_temp_filename(file_path, index, code_type): def process_markdown_file(file_path, temp_dir, process_python=True, process_bash=True, verbose=False): - """Processes a Markdown file, extracting code blocks for formatting and updating the original file.""" + """Processes a Markdown file, extracting code blocks into temp files and returning the content and file info.""" try: markdown_content = Path(file_path).read_text(encoding="utf-8") code_blocks_by_type = extract_code_blocks(markdown_content) diff --git a/actions/utils/openai_utils.py b/actions/utils/openai_utils.py index 0b421b5..ff92126 100644 --- a/actions/utils/openai_utils.py +++ b/actions/utils/openai_utils.py @@ -75,7 +75,7 @@ def remove_outer_codeblocks(string): def filter_labels(available_labels: dict, current_labels: list | None = None, is_pr: bool = False) -> dict: - """Filters labels by removing manually-assigned and mutually exclusive labels.""" + """Filters labels by removing manually-assigned and mutually exclusive labels, adding an Alert label if absent.""" current_labels = current_labels or [] filtered = available_labels.copy() diff --git a/dependabot/README.md b/dependabot/README.md index 49469b0..9e19638 100644 --- a/dependabot/README.md +++ b/dependabot/README.md @@ -1,6 +1,6 @@ # Dependabot Action -Update GitHub Actions versions across organization repos with cached version resolution. Designed for private/internal repos where GitHub's built-in Dependabot is not available. +Update GitHub Actions versions across organization repos with cached version resolution. Provides centralized, org-wide updates (including private/internal repos) without per-repo Dependabot configuration. ## Usage diff --git a/dependabot/action.yml b/dependabot/action.yml index 2bbe46c..e0e9be7 100644 --- a/dependabot/action.yml +++ b/dependabot/action.yml @@ -2,7 +2,7 @@ name: "Dependabot" author: "Ultralytics" -description: "Update GitHub Actions versions across organization repos with cached lookups. Designed for private repos where GitHub Dependabot is not available." +description: "Update GitHub Actions versions across organization repos with cached lookups. A centralized alternative to per-repo Dependabot configuration." branding: icon: "refresh-cw" color: "blue" diff --git a/scan-prs/README.md b/scan-prs/README.md index be72cd8..53a759e 100644 --- a/scan-prs/README.md +++ b/scan-prs/README.md @@ -1,11 +1,11 @@ # Scan PRs Action -List open PRs across an organization and auto-merge eligible Dependabot PRs. +List open PRs across an organization and auto-merge eligible GitHub Actions update PRs. ## Features - **PR Overview**: Lists all open PRs with age-based categorization (New, Green ≤7d, Yellow ≤30d, Red >30d) -- **Auto-merge**: Automatically merges Dependabot PRs that update GitHub Actions workflows when all checks pass +- **Auto-merge**: Automatically merges Dependabot and UltralyticsAssistant PRs that update GitHub Actions when no checks have failed - **Console Logging**: Detailed output showing which PRs were found, merged, or skipped with reasons ## Usage @@ -44,12 +44,14 @@ jobs: ## Auto-merge Criteria -Dependabot PRs are automatically merged if they meet ALL criteria: +GitHub Actions update PRs are automatically merged if they meet ALL criteria: -1. Update files in `.github/workflows/` only -2. PR is mergeable (no conflicts) -3. All status checks passed (SUCCESS, SKIPPED, or NEUTRAL) -4. Maximum 1 PR merged per repository per run +1. Authored by Dependabot or UltralyticsAssistant +2. Title contains `bump` and `/.github/workflows` (a GitHub Actions version bump) +3. Update at least one GitHub Actions file (in `.github/workflows/`, or an `action.yml`/`action.yaml`) +4. PR is mergeable (no conflicts) +5. No status checks in a failed state (`FAILURE`, `ERROR`, `CANCELLED`, `TIMED_OUT`, `ACTION_REQUIRED`, `STARTUP_FAILURE`); pending or absent checks do not block merging +6. Maximum 1 PR merged per repository per run ## Output @@ -58,4 +60,4 @@ The action generates a GitHub step summary with: - Total PR count across all repos - PR breakdown by phase (New, Green, Yellow, Red) - Detailed list of PRs per repository -- Summary of Dependabot PRs found, merged, and skipped +- Summary of GitHub Actions update PRs found, merged, and skipped diff --git a/scan-prs/action.yml b/scan-prs/action.yml index 66a3289..fad64c2 100644 --- a/scan-prs/action.yml +++ b/scan-prs/action.yml @@ -2,7 +2,7 @@ name: "Scan PRs" author: "Ultralytics" -description: "List open PRs and auto-merge eligible Dependabot PRs across organization" +description: "List open PRs and auto-merge eligible GitHub Actions update PRs across organization" branding: icon: "git-pull-request" color: "blue"