9
9
description : ' Input directory containing API source code (relative to workspace). Defaults to project root.'
10
10
required : false
11
11
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
12
17
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. '
14
19
required : false
15
20
default : false
16
21
type : boolean
39
44
-v "${{ github.workspace }}/generated-mcp:/app/output" \
40
45
ghcr.io/codeglide/mcpgen:latest
41
46
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 }}
44
49
shell : bash
50
+ id : branch_creation
51
+ continue-on-error : true
52
+ env :
53
+ GH_TOKEN : ${{ github.token }}
45
54
run : |
46
55
# Configure git with GitHub Actions identity
47
56
git config --global user.name "codeglide-github-actions[bot]"
@@ -62,17 +71,47 @@ runs:
62
71
git commit -m "feat: codeglide Auto-generated MCP server code
63
72
64
73
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.
66
87
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
72
108
73
109
- 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') }}
75
111
uses : actions/upload-artifact@v4
76
112
with :
77
113
name : generated-mcp
78
114
path : generated-mcp/
115
+
116
+
117
+
0 commit comments