forked from browserbase/stagehand-python
-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (120 loc) · 5.6 KB
/
feature-parity.yml
File metadata and controls
145 lines (120 loc) · 5.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Feature Parity
on:
pull_request:
types:
- opened
- synchronize
- labeled
- unlabeled
jobs:
check-parity-label:
runs-on: ubuntu-latest
if: github.event.action == 'labeled' && github.event.label.name == 'parity'
permissions:
contents: read
pull-requests: write
issues: write
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Check user permissions
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: permission } = await github.rest.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner,
repo: context.repo.repo,
username: context.actor
});
const hasWriteAccess = ['admin', 'write'].includes(permission.permission);
if (!hasWriteAccess) {
// Remove the parity label if user doesn't have write access
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
name: 'parity'
});
// Add a comment explaining why the label was removed
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `❌ **Parity Label Removed**\n\n@${context.actor}, you do not have sufficient permissions to add the 'parity' label. Only users with write access can trigger feature parity issues.\n\nIf you believe this feature should be implemented in the Typescript SDK, please ask a maintainer to add the label.`
});
throw new Error(`User ${context.actor} does not have write access to add parity label`);
}
console.log(`User ${context.actor} has ${permission.permission} access - proceeding with parity workflow`);
- name: Generate GitHub App token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.PARITY_APP_ID }}
private-key: ${{ secrets.PARITY_APP_PRIVATE_KEY }}
owner: browserbase
repositories: stagehand-python
- name: Create issue in Python SDK repository
uses: actions/github-script@v7
with:
github-token: ${{ steps.generate-token.outputs.token }}
script: |
const { data: pullRequest } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
});
// Get PR comments for additional context
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
// Format comments for the issue description
let commentsSection = '';
if (comments.length > 0) {
commentsSection = '\n\n## Recent Comments\n\n';
comments.slice(-3).forEach(comment => {
commentsSection += `**@${comment.user.login}** commented:\n`;
commentsSection += `${comment.body.substring(0, 500)}${comment.body.length > 500 ? '...' : ''}\n\n`;
});
}
// Get list of changed files for context
const { data: files } = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
});
const changedFiles = files.map(file => `- \`${file.filename}\``).join('\n');
const issueTitle = `[Feature Parity] ${pullRequest.title}`;
const issueBody = `## Feature Parity Request
This issue was automatically created from a pull request in the Python Stagehand repository that was labeled with 'parity'.
### Original PR Details
- **PR**: #${context.issue.number} - ${pullRequest.title}
- **Author**: @${pullRequest.user.login}
- **Link**: ${pullRequest.html_url}
### Description
${pullRequest.body || 'No description provided.'}
### Changed Files
${changedFiles}
${commentsSection}
### Action Required
Please review the changes in the original PR and implement equivalent functionality in the Typescript SDK if applicable.
---
*This issue was automatically generated by the Feature Parity workflow.*`;
// Create the issue in the Typescript repository
const { data: issue } = await github.rest.issues.create({
owner: 'browserbase',
repo: 'stagehand',
title: issueTitle,
body: issueBody,
labels: ['parity']
});
console.log(`Created issue: ${issue.html_url}`);
// Add a comment to the original PR confirming the issue was created
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `🔄 **Feature Parity Issue Created**\n\nAn issue has been automatically created in the Typescript SDK repository to track parity implementation:\n${issue.html_url}`
});