Skip to content

Commit eef899c

Browse files
fix: update sync workflows to create PRs instead of pushing to main (#76)
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 Co-authored-by: openhands <[email protected]>
1 parent b0930e3 commit eef899c

File tree

2 files changed

+58
-22
lines changed

2 files changed

+58
-22
lines changed

.github/workflows/sync-agent-sdk-openapi.yml

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212

1313
permissions:
1414
contents: write
15+
pull-requests: write
1516

1617
jobs:
1718
sync-openapi:
@@ -69,19 +70,38 @@ jobs:
6970
echo "changes=false" >> "$GITHUB_OUTPUT"
7071
fi
7172
72-
- name: Commit and push OpenAPI spec
73+
- name: Get commit info
7374
if: steps.detect_changes.outputs.changes == 'true'
75+
id: commit_info
7476
run: |
75-
set -euo pipefail
76-
git add openapi/agent-sdk.json
77-
# Re-check in case only unrelated files changed
78-
if git diff --cached --quiet; then
79-
echo "No OpenAPI changes to commit."
80-
exit 0
81-
fi
82-
8377
SHA_SHORT="$(git -C agent-sdk rev-parse --short=7 HEAD || echo manual)"
8478
BRANCH="${AGENT_SDK_REF:-main}"
79+
echo "sha_short=${SHA_SHORT}" >> "$GITHUB_OUTPUT"
80+
echo "branch=${BRANCH}" >> "$GITHUB_OUTPUT"
81+
82+
- name: Create Pull Request
83+
if: steps.detect_changes.outputs.changes == 'true'
84+
uses: peter-evans/create-pull-request@v7
85+
with:
86+
add-paths: openapi/agent-sdk.json
87+
commit-message: "sync(openapi): agent-sdk/${{ steps.commit_info.outputs.branch }} ${{ steps.commit_info.outputs.sha_short }}"
88+
branch: sync-openapi
89+
branch-suffix: timestamp
90+
delete-branch: true
91+
title: "sync(openapi): agent-sdk/${{ steps.commit_info.outputs.branch }} ${{ steps.commit_info.outputs.sha_short }}"
92+
body: |
93+
## Summary of changes
94+
95+
This PR automatically syncs the OpenAPI specification from the agent-sdk repository.
96+
97+
**Agent SDK Reference**: `${{ steps.commit_info.outputs.branch }}` (commit: `${{ steps.commit_info.outputs.sha_short }}`)
98+
99+
### Changes Made
100+
- Updated `openapi/agent-sdk.json` with the latest OpenAPI spec from agent-sdk
101+
- This is an automated sync performed by the `sync-agent-sdk-openapi` workflow
102+
103+
### Checklist
104+
- [x] I have read and reviewed the documentation changes to the best of my ability.
105+
- [x] If the change is significant, I have run the documentation site locally and confirmed it renders as expected.
85106
86-
git commit -m "sync(openapi): agent-sdk/${BRANCH} ${SHA_SHORT}"
87-
git push
107+
**Note**: This is an automated pull request. Please review the changes to ensure they are correct before merging.

.github/workflows/sync-docs-code-blocks.yml

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,31 @@ jobs:
5252
echo "changes=false" >> "$GITHUB_OUTPUT"
5353
fi
5454
55-
- name: Commit and push changes
56-
if: steps.detect_changes.outputs.changes == 'true' # <-- updated reference
57-
shell: bash
58-
run: |
59-
set -euo pipefail
60-
git config --global user.name "github-actions[bot]"
61-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
62-
git add -A
63-
git commit -m "docs: sync code blocks from agent-sdk examples
55+
- name: Create Pull Request
56+
if: steps.detect_changes.outputs.changes == 'true'
57+
uses: peter-evans/create-pull-request@v7
58+
with:
59+
commit-message: |
60+
docs: sync code blocks from agent-sdk examples
61+
62+
Synced from agent-sdk ref: ${{ github.event.inputs.agent_sdk_ref || 'main' }}
63+
branch: sync-docs-code-blocks
64+
branch-suffix: timestamp
65+
delete-branch: true
66+
title: "docs: sync code blocks from agent-sdk examples"
67+
body: |
68+
## Summary of changes
69+
70+
This PR automatically syncs code blocks in documentation with their corresponding source files from the agent-sdk repository.
71+
72+
**Agent SDK Reference**: `${{ github.event.inputs.agent_sdk_ref || 'main' }}`
73+
74+
### Changes Made
75+
- Updated code blocks in MDX files to match the current state of example files in agent-sdk
76+
- This is an automated sync performed by the `sync-docs-code-blocks` workflow
77+
78+
### Checklist
79+
- [x] I have read and reviewed the documentation changes to the best of my ability.
80+
- [x] If the change is significant, I have run the documentation site locally and confirmed it renders as expected.
6481
65-
Synced from agent-sdk ref: ${{ github.event.inputs.agent_sdk_ref || 'main' }}"
66-
git push
82+
**Note**: This is an automated pull request. Please review the changes to ensure they are correct before merging.

0 commit comments

Comments
 (0)