Skip to content

Instantly share code, notes, and snippets.

@DaRaFF
Last active October 19, 2018 09:49
Show Gist options
  • Save DaRaFF/bf4cc94045cbb6e8175eca7fde1e46f6 to your computer and use it in GitHub Desktop.
Save DaRaFF/bf4cc94045cbb6e8175eca7fde1e46f6 to your computer and use it in GitHub Desktop.
Creates a Downstream Integration Branch PR for Release Management of Livingdocs

Creates a new downstream integration PR

e.g. upstream-release-2018-08 against upstream-release-2018-06

Example

# GH_REPO_NAME e.g. livingdocs-bluewin-server
# GH_REPO_OWNER e.g. livingdocsIO
# GH_BRANCH_NAME e.g. upstream-release-2018-08 // pr will be created on this branch
# GH_BASE_BRANCH_NAME e.g. upstream-release-2018-06 // pr will be created against this branch
# RELEASE_NAME e.g. "September 2018"
# GH_TOKEN e.g. 123f345f11234 // github token

RELEASE_NAME=<name> GH_BASE_BRANCH_NAME=<name> GH_BRANCH_NAME=<name> GH_REPO_NAME=<name> GH_TOKEN=<token>
GH_REPO_NAME=<name> npx <this url>
#!/usr/bin/env node
const octokit = require('@octokit/rest')()
const assert = require('assert')
assert(process.env.GH_TOKEN, 'missing environment variable GH_TOKEN e.g 11b22b33n4')
const token = process.env.GH_TOKEN
assert(process.env.GH_REPO_OWNER, 'missing environment variable GH_REPO_OWNER e.g livingdocsIO')
const owner = process.env.GH_REPO_OWNER
assert(process.env.GH_REPO_NAME, 'missing environment variable GH_REPO_NAME e.g livingdocs-bluewin-editor')
const repo = process.env.GH_REPO_NAME
assert(process.env.GH_BRANCH_NAME, 'missing environment variable GH_BRANCH_NAME e.g upstream-release-2018-08')
const branchName = process.env.GH_BRANCH_NAME
assert(process.env.GH_BASE_BRANCH_NAME, 'missing environment variable GH_BASE_BRANCH_NAME e.g upstream-release-2018-06')
const baseBranchName = process.env.GH_BASE_BRANCH_NAME
assert(process.env.RELEASE_NAME, 'missing environment variable RELEASE_NAME e.g September 2018')
const releaseName = process.env.RELEASE_NAME
const body = `
Relations:
* server: <link>
Upstream Versions:
- Server: \`vX.Y.Z\`
- Editor: \`vX.Y.Z\`
# Integrated Upstream Breaking Changes
[0.0.0](https://github.com/livingdocsIO/${repo}/releases/tag/v0.0.0) - some description
`
octokit.authenticate({
type: 'token',
token: token
})
async function createPullRequest() {
return await octokit.pullRequests.create({
owner: owner,
repo: repo,
title: `Livingdocs ${releaseName} Release`,
head: branchName,
base: baseBranchName,
body: body,
maintainer_can_modify: true
})
}
createPullRequest()
.then(response => {
console.log(`The PR has been opened at ${response.data.html_url}`)
})
.catch(e => {
console.log(e)
})
{
"name": "create-downstream-release-pull",
"version": "1.0.0",
"bin": "./create-downstream-release-pull.js",
"dependencies": {
"@octokit/rest": "^15.9.4"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment