Skip to content

Commit 862d8ba

Browse files
CopilotMohabMohie
andauthored
Fix sync-versions pipeline to comply with repository rules using Pull Request workflow (#31)
* Initial plan * Update sync-versions workflow to use PR instead of direct push Co-authored-by: MohabMohie <19201898+MohabMohie@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: MohabMohie <19201898+MohabMohie@users.noreply.github.com>
1 parent 79b86f9 commit 862d8ba

File tree

1 file changed

+38
-8
lines changed

1 file changed

+38
-8
lines changed

.github/workflows/sync-versions.yml

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
runs-on: ubuntu-22.04
1414
permissions:
1515
contents: write
16+
pull-requests: write
1617
steps:
1718
- name: Checkout Code
1819
uses: actions/checkout@v5
@@ -94,13 +95,17 @@ jobs:
9495
echo "=== Checking for old version references ==="
9596
grep -n "$CURRENT_PROJECT_VERSION" pom.xml Dockerfile src/main/resources/application.properties readme.md || echo "No old version references found (expected)"
9697
97-
- name: Commit and push changes
98+
- name: Create PR with version sync changes
9899
if: steps.check_sync.outputs.sync_needed == 'true'
99100
run: |
100101
# Configure git
101102
git config --global user.name 'github-actions[bot]'
102103
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
103104
105+
# Create a new branch for the changes
106+
BRANCH_NAME="sync-versions-to-$SHAFT_ENGINE_VERSION"
107+
git checkout -b "$BRANCH_NAME"
108+
104109
# Stage changes
105110
git add pom.xml Dockerfile src/main/resources/application.properties readme.md
106111
@@ -113,23 +118,48 @@ jobs:
113118
114119
- Updated project version in pom.xml
115120
- Updated Dockerfile Maven Central URL
116-
- Updated application.properties MCP server version
121+
- Updated application.properties MCP server version
117122
- Updated readme.md version references
118123
119124
This automated update keeps all version references in sync with the SHAFT Engine version."
120125
121-
# Push changes
122-
git push
123-
echo "Changes committed and pushed successfully"
126+
# Push changes to the new branch
127+
git push origin "$BRANCH_NAME"
128+
echo "Changes committed and pushed to branch $BRANCH_NAME"
129+
130+
# Create a pull request using GitHub CLI
131+
PR_BODY="## Version Sync Update
132+
133+
This automated PR syncs the project version with the SHAFT Engine version.
134+
135+
### Changes
136+
- ✅ Updated project version in \`pom.xml\` from \`$CURRENT_PROJECT_VERSION\` to \`$SHAFT_ENGINE_VERSION\`
137+
- ✅ Updated Dockerfile Maven Central URL
138+
- ✅ Updated \`application.properties\` MCP server version
139+
- ✅ Updated \`readme.md\` version references
140+
141+
### Review
142+
Please review and merge this PR to complete the version sync process."
143+
144+
gh pr create \
145+
--title "🔄 Auto-sync project version to $SHAFT_ENGINE_VERSION" \
146+
--body "$PR_BODY" \
147+
--base main \
148+
--head "$BRANCH_NAME"
149+
150+
echo "Pull request created successfully"
124151
fi
152+
env:
153+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125154

126155
- name: Create summary
127156
run: |
128157
if [ "${{ steps.check_sync.outputs.sync_needed }}" == "true" ]; then
129-
echo "✅ **Version Sync Completed**" >> $GITHUB_STEP_SUMMARY
130-
echo "- Project version updated from \`$CURRENT_PROJECT_VERSION\` to \`$SHAFT_ENGINE_VERSION\`" >> $GITHUB_STEP_SUMMARY
158+
echo "✅ **Version Sync PR Created**" >> $GITHUB_STEP_SUMMARY
159+
echo "- Project version will be updated from \`$CURRENT_PROJECT_VERSION\` to \`$SHAFT_ENGINE_VERSION\`" >> $GITHUB_STEP_SUMMARY
160+
echo "- A pull request has been created for review and merge" >> $GITHUB_STEP_SUMMARY
131161
echo "- Updated files: pom.xml, Dockerfile, application.properties, readme.md" >> $GITHUB_STEP_SUMMARY
132162
else
133163
echo "ℹ️ **No Sync Needed**" >> $GITHUB_STEP_SUMMARY
134164
echo "- Project version (\`$CURRENT_PROJECT_VERSION\`) already matches SHAFT Engine version" >> $GITHUB_STEP_SUMMARY
135-
fi
165+
fi

0 commit comments

Comments
 (0)