Refactor SEO workflow to use GitHub API for changed files#24004
Conversation
Replaces git diff logic with GitHub API to reliably detect added/modified markdown files in docs/en/ from merged PRs. Improves branch creation and file processing steps, ensuring only relevant files are handled for SEO updates.
There was a problem hiding this comment.
Pull Request Overview
This PR modernizes the SEO workflow by replacing shell-based git diff operations with the GitHub API to detect changed markdown files in pull requests. The refactor improves reliability and maintainability by using actions/github-script to retrieve file changes with pagination support.
Key Changes:
- Switched from git diff commands to GitHub REST API for detecting changed files
- Added pagination support to handle PRs with more than 100 changed files
- Simplified branch creation logic by checking out the base branch directly
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| uses: actions/checkout@v4 | ||
| with: | ||
| ref: ${{ github.event.pull_request.merge_commit_sha }} | ||
| ref: ${{ github.event.pull_request.base.ref }} |
There was a problem hiding this comment.
Checking out the base branch will not include the merged changes from the PR. Since this workflow triggers on 'closed' with 'merged: true', you need the merged state. Consider using github.event.pull_request.merge_commit_sha or checking out the base branch and then merging/cherry-picking the PR changes.
| ref: ${{ github.event.pull_request.base.ref }} | |
| ref: ${{ github.event.pull_request.merge_commit_sha }} |
| BRANCH_NAME="auto-docs-seo/${{ github.event.pull_request.number }}" | ||
| git commit -m "docs: Add SEO descriptions to modified documentation files" -m "Related to PR #${{ github.event.pull_request.number }}" | ||
| git push origin ${{ env.BRANCH_NAME }} | ||
| git push origin $BRANCH_NAME |
There was a problem hiding this comment.
The BRANCH_NAME variable is redefined here but was already set in the 'Create new branch for SEO updates' step (line 96) and exported to GITHUB_ENV. This duplication is unnecessary and could lead to inconsistencies if the naming pattern changes. Use ${{ env.BRANCH_NAME }} instead.
No description provided.