Skip to content

Commit d845128

Browse files
authored
Update action.yml
PR creation feature
1 parent 295aff4 commit d845128

File tree

1 file changed

+49
-10
lines changed

1 file changed

+49
-10
lines changed

action.yml

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ inputs:
99
description: 'Input directory containing API source code (relative to workspace). Defaults to project root.'
1010
required: false
1111
default: '.'
12+
create_pr:
13+
description: 'Create PR with generated code. Falls back to branch/commit or artifact upload if no push permissions.'
14+
required: false
15+
default: false
16+
type: boolean
1217
create_branch_and_commit:
13-
description: 'Create Branch and commit with generated code. Else, MCP is uploaded as artifact'
18+
description: 'Create branch and commit with generated code. Falls back to artifact upload if no push permissions.'
1419
required: false
1520
default: false
1621
type: boolean
@@ -39,9 +44,13 @@ runs:
3944
-v "${{ github.workspace }}/generated-mcp:/app/output" \
4045
ghcr.io/codeglide/mcpgen:latest
4146
42-
- name: Create Branch and commit
43-
if: ${{ inputs.create_branch_and_commit }}
47+
- name: Create PR / Branch
48+
if: ${{ inputs.create_pr || inputs.create_branch_and_commit }}
4449
shell: bash
50+
id: branch_creation
51+
continue-on-error: true
52+
env:
53+
GH_TOKEN: ${{ github.token }}
4554
run: |
4655
# Configure git with GitHub Actions identity
4756
git config --global user.name "codeglide-github-actions[bot]"
@@ -62,17 +71,47 @@ runs:
6271
git commit -m "feat: codeglide Auto-generated MCP server code
6372
6473
Triggered by: @${{ github.actor }}"
65-
git push origin $BRANCH_NAME
74+
75+
# Try to push the branch
76+
if git push origin $BRANCH_NAME; then
77+
echo "Branch created and pushed successfully!"
78+
echo "Branch name: $BRANCH_NAME"
79+
80+
# Try to create PR if requested
81+
if [[ "${{ inputs.create_pr }}" == "true" ]]; then
82+
if gh pr create \
83+
--base "${{ github.ref_name }}" \
84+
--head "$BRANCH_NAME" \
85+
--title "feat: Update MCP server with latest generated code" \
86+
--body "Auto generated PR with MCP server code by CodeGlide.
6687
67-
echo "Branch created and pushed successfully!"
68-
echo "Branch name: $BRANCH_NAME"
69-
echo ""
70-
echo "To create a PR, visit:"
71-
echo "https://github.com/${{ github.repository }}/compare/main...$BRANCH_NAME"
88+
**Generated from:** \`${{ inputs.input_directory }}\`
89+
**Generated by:** CodeGlide MCP Generator
90+
**Triggered by:** @${{ github.actor }}" > /dev/null 2>&1; then
91+
echo "Pull request created successfully!"
92+
echo "View PR at: https://github.com/${{ github.repository }}/pull/..."
93+
else
94+
echo "Could not create PR (insufficient permissions)"
95+
echo "To create a PR manually, visit:"
96+
echo "https://github.com/${{ github.repository }}/compare/${{ github.ref_name }}...$BRANCH_NAME"
97+
fi
98+
else
99+
echo "To create a PR manually, visit:"
100+
echo "https://github.com/${{ github.repository }}/compare/${{ github.ref_name }}...$BRANCH_NAME"
101+
fi
102+
echo "success=true" >> $GITHUB_OUTPUT
103+
else
104+
echo "Failed to push branch. Will upload as artifact instead."
105+
echo "success=false" >> $GITHUB_OUTPUT
106+
exit 1
107+
fi
72108
73109
- name: Upload MCP Server
74-
if: ${{ !inputs.create_branch_and_commit }}
110+
if: ${{ !inputs.create_pr && !inputs.create_branch_and_commit || (steps.branch_creation.outputs.success != 'true') }}
75111
uses: actions/upload-artifact@v4
76112
with:
77113
name: generated-mcp
78114
path: generated-mcp/
115+
116+
117+

0 commit comments

Comments
 (0)