-
Notifications
You must be signed in to change notification settings - Fork 3.7k
64 lines (63 loc) · 2.65 KB
/
pr_check_client_side_changes.yml
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
name: "Check client side changes"
on:
push:
branches:
- main
paths:
- 'docs/src/api/**/*'
- 'packages/playwright-core/src/client/**/*'
- 'packages/playwright-core/src/utils/isomorphic/**/*'
- 'packages/playwright/src/matchers/matchers.ts'
- 'packages/protocol/src/protocol.yml'
jobs:
check:
name: Check
runs-on: ubuntu-24.04
if: github.repository == 'microsoft/playwright'
steps:
- uses: actions/checkout@v4
- name: Create GitHub issue
uses: actions/github-script@v7
with:
github-token: ${{ secrets.REPOSITORY_DISPATCH_PERSONAL_ACCESS_TOKEN }}
script: |
const currentPlaywrightVersion = require('./package.json').version.match(/\d+\.\d+/)[0];
const { data } = await github.rest.git.getCommit({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: context.sha,
});
const commitHeader = data.message.split('\n')[0];
const prMatch = commitHeader.match(/#(\d+)/);
const formattedCommit = prMatch
? `https://github.com/microsoft/playwright/pull/${prMatch[1]}`
: `https://github.com/${context.repo.owner}/${context.repo.repo}/commit/${context.sha} (${commitHeader})`;
const title = '[Ports]: Backport client side changes for ' + currentPlaywrightVersion;
for (const repo of ['playwright-python', 'playwright-java', 'playwright-dotnet']) {
const { data: issuesData } = await github.rest.search.issuesAndPullRequests({
q: `is:issue is:open repo:microsoft/${repo} in:title "${title}" author:playwrightmachine`
})
let issueNumber = null;
let issueBody = '';
if (issuesData.total_count > 0) {
issueNumber = issuesData.items[0].number
issueBody = issuesData.items[0].body
} else {
const { data: issueCreateData } = await github.rest.issues.create({
owner: context.repo.owner,
repo: repo,
title,
body: 'Please backport client side changes: \n',
});
issueNumber = issueCreateData.number;
issueBody = issueCreateData.body;
}
const newBody = issueBody.trimEnd() + `
- [ ] ${formattedCommit}`;
const data = await github.rest.issues.update({
owner: context.repo.owner,
repo: repo,
issue_number: issueNumber,
body: newBody
})
}