remix-project mirror
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
remix-project/createPRToBeta.ts

49 lines
1.5 KiB

10 months ago
// 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
10 months ago
// Command to run this script: fromPR=4369 authToken=abc123 yarn run createPRToBeta
10 months ago
10 months ago
import { Octokit } from "octokit"
10 months ago
async function createPR (prNumber, baseBranch) {
10 months ago
try {
10 months ago
if (!prNumber) throw new Error(`Please provide a PR number with 'fromPR' env variable`)
const octokit = new Octokit({
10 months ago
auth: process.env.authToken || ''
})
10 months ago
10 months ago
const owner = 'ethereum'
const repo = 'remix-project'
10 months ago
const prData = await octokit.request('GET /repos/{owner}/{repo}/pulls/{pull_number}', {
10 months ago
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', {
10 months ago
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)
10 months ago
10 months ago
} catch (error) {
console.error('Error during PR creation: ', error.message)
}
}
11 months ago
createPR(process.env.fromPR, 'remix_beta')