-
Notifications
You must be signed in to change notification settings - Fork 0
/
createPRToBeta.ts
48 lines (39 loc) · 1.5 KB
/
createPRToBeta.ts
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
// This script can be used to open a PR for base branch 'remix_beta' using an existing pull request
// Pull request number should be provided while running this script
// It will use the reference branch same as the shared PR
// To create a new PR, Github auth token with scope 'repo' needs to be provided
// Command to run this script: fromPR=4369 authToken=abc123 yarn run createPRToBeta
import { Octokit } from "octokit"
async function createPR (prNumber, baseBranch) {
try {
if (!prNumber) throw new Error(`Please provide a PR number with 'fromPR' env variable`)
const octokit = new Octokit({
auth: process.env.authToken || ''
})
const owner = 'ethereum'
const repo = 'remix-project'
const prData = await octokit.request('GET /repos/{owner}/{repo}/pulls/{pull_number}', {
owner: owner,
repo: repo,
pull_number: prNumber,
headers: {
'X-GitHub-Api-Version': '2022-11-28'
}
})
const response = await octokit.request('POST /repos/{owner}/{repo}/pulls', {
owner: owner,
repo: repo,
title: prData.data.title + ' (for beta)',
body: prData.data.body + ' (for beta)',
head: prData.data.head.ref,
base: baseBranch,
headers: {
'X-GitHub-Api-Version': '2022-11-28'
}
})
console.log('Pull Request Created!!! See: ', response.data.html_url)
} catch (error) {
console.error('Error during PR creation: ', error.message)
}
}
createPR(process.env.fromPR, 'remix_beta')