Skip to content

Conversation

@xingyaoww
Copy link
Contributor

  • I have read and reviewed the documentation changes to the best of my ability.
  • If the change is significant, I have run the documentation site locally and confirmed it renders as expected.

Summary of changes

This PR fixes issue #75 by modifying both sync workflows to create pull requests automatically instead of pushing directly to the main branch.

Problem

The current sync workflows (sync-docs-code-blocks and sync-agent-sdk-openapi) attempt to push directly to the main branch, which is blocked by repository branch protection rules that require changes to be made through pull requests. This causes the workflows to fail with the error:

remote: error: GH013: Repository rule violations found for refs/heads/main.
remote: - Changes must be made through a pull request.

Solution

Updated both workflows to:

  1. Create a unique branch with a timestamp (e.g., sync-docs-code-blocks-20250104-020000)
  2. Commit changes to the new branch
  3. Push the branch to the repository
  4. Automatically create a pull request using GitHub CLI (gh pr create)
  5. Include all required checklist items from the PR template in the PR description

Changes Made

sync-docs-code-blocks.yml

  • Renamed step from "Commit and push changes" to "Create Pull Request"
  • Added branch creation with unique timestamp-based name
  • Replaced direct push with PR creation via GitHub CLI
  • Added comprehensive PR description with checklist items

sync-agent-sdk-openapi.yml

  • Added pull-requests: write permission
  • Renamed step from "Commit and push OpenAPI spec" to "Create Pull Request"
  • Added branch creation with unique timestamp-based name
  • Replaced direct push with PR creation via GitHub CLI
  • Added comprehensive PR description with checklist items

Testing

The workflows will now:

  • Run on schedule (daily at 2 AM UTC)
  • Detect changes in documentation code blocks or OpenAPI specs
  • Automatically create a pull request if changes are detected
  • Allow maintainers to review and merge the changes

Fixes #75

@xingyaoww can click here to continue refining the PR

This fixes issue #75 by replacing manual PR creation with the popular
peter-evans/create-pull-request@v7 GitHub Action, which provides:
- Cleaner, more maintainable code
- Automatic branch management with timestamps
- Built-in handling of edge cases
- Automatic cleanup of merged branches

Changes:
- Replaced custom bash/gh cli scripts with peter-evans/create-pull-request action
- Simplified both sync-docs-code-blocks.yml and sync-agent-sdk-openapi.yml
- Maintained all PR template requirements and descriptions
- Added automatic branch deletion after merge (delete-branch: true)
- Uses timestamp-based branch suffixes for uniqueness

The workflows now use industry-standard GitHub Actions instead of custom
shell scripts, making them more reliable and easier to maintain.

Fixes #75
@xingyaoww xingyaoww force-pushed the openhands/fix-sync-workflow-push-to-main branch from ec79008 to 767ba48 Compare November 4, 2025 20:03
@xingyaoww xingyaoww merged commit eef899c into main Nov 4, 2025
2 checks passed
@xingyaoww xingyaoww deleted the openhands/fix-sync-workflow-push-to-main branch November 4, 2025 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sync code blocks is not working on main

3 participants