|
60 | 60 | throw new Error(`Don't know how to handle event name: ${eventName}`);
|
61 | 61 | }
|
62 | 62 |
|
63 |
| - // Create pull request |
64 |
| - const createResp = await github.rest.pulls.create({ |
| 63 | + // Create pull request as Apify Service Account |
| 64 | + // Apify Service Account does not trigger PR toolkit, |
| 65 | + // does not need approval for PRs and does not need to wait for status checks |
| 66 | + const createResp = await octokit.rest.pulls.create({ |
65 | 67 | owner: context.repo.owner,
|
66 | 68 | repo: context.repo.repo,
|
67 | 69 | head: headBranch,
|
|
71 | 73 |
|
72 | 74 | const pullRequestNumber = createResp.data.number;
|
73 | 75 |
|
74 |
| - // Approve pull request |
75 |
| - await octokit.request('POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews', { |
76 |
| - owner: context.repo.owner, |
77 |
| - repo: context.repo.repo, |
78 |
| - pull_number: pullRequestNumber, |
79 |
| - body: 'Auto-approving pull request', |
80 |
| - event: 'APPROVE', |
81 |
| - }) |
82 |
| -
|
83 |
| - // Wait for PR toolkit to finish (up to 3 minutes) on the pull request |
84 |
| - let i = 0; |
85 |
| - let prToolkitSuccessful = false; |
86 |
| - while (i++ < 60) { |
87 |
| - const resp = await github.rest.checks.listForRef({ |
88 |
| - owner: context.repo.owner, |
89 |
| - repo: context.repo.repo, |
90 |
| - ref: `pull/${pullRequestNumber}/head`, |
91 |
| - check_name: 'apify-pr-toolkit', |
92 |
| - }); |
93 |
| -
|
94 |
| - if (resp.data.check_runs.length > 1) { |
95 |
| - throw new Error('There are more than one PR toolkit runs, this should be impossible'); |
96 |
| - } |
97 |
| -
|
98 |
| - if (resp.data.check_runs.length === 1 && resp.data.check_runs[0].status === 'completed') { |
99 |
| - if (resp.data.check_runs[0].conclusion === 'success') { |
100 |
| - console.log('PR toolkit succeeded'); |
101 |
| - prToolkitSuccessful = true; |
102 |
| - break; |
103 |
| - } else { |
104 |
| - throw new Error('PR toolkit failed'); |
105 |
| - } |
106 |
| - } |
107 |
| -
|
108 |
| - await new Promise((resolve) => setTimeout(resolve, 3000)); |
109 |
| - } |
110 |
| - if (!prToolkitSuccessful) { |
111 |
| - throw new Error('PR toolkit check did not finish in time'); |
112 |
| - } |
113 |
| -
|
114 | 76 | // Merge pull request
|
115 | 77 | await github.rest.pulls.merge({
|
116 | 78 | owner: context.repo.owner,
|
|
0 commit comments