-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
74 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
scripts/gatsby-changelog-generator/lerna-version-lifecycle.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
const { onVersion } = require(`./generate`) | ||
onVersion().catch(console.error) | ||
const { onNewVersion } = require(`./generate`) | ||
onNewVersion().catch(console.error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
const execa = require(`execa`) | ||
const { getAllPackageNames, updateChangelog } = require(`./generate`) | ||
|
||
if (!process.env.GITHUB_ACCESS_TOKEN) { | ||
throw new Error(`GITHUB_ACCESS_TOKEN env var not set`) | ||
} | ||
|
||
async function run() { | ||
await execa(`git`, [`checkout`, `master`]) | ||
await execa(`git`, [`pull`, `--tags`]) | ||
|
||
const updatedPackages = [] | ||
for (const pkg of getAllPackageNames()) { | ||
try { | ||
const updated = await updateChangelog(pkg) | ||
if (updated) { | ||
updatedPackages.push(pkg) | ||
} | ||
} catch (e) { | ||
console.error(`${pkg}: ${e.stack}`) | ||
} | ||
} | ||
|
||
if (!updatedPackages.length) { | ||
console.log(`Nothing to do`) | ||
return | ||
} | ||
|
||
// Commit to the same branch | ||
const branchName = `bot-changelog-update` | ||
const commitMessage = `DO NOT MERGE: testing` | ||
try { | ||
await execa(`git`, [`checkout`, `-b`, branchName, `origin/${branchName}`]) | ||
} catch { | ||
await execa(`git`, [`checkout`, branchName]) | ||
} | ||
await execa(`git`, [`commit`, `-m`, commitMessage]) | ||
|
||
try { | ||
const pr = await octokit.pulls.create({ | ||
owner: `gatsby`, | ||
repo: `gatsbyjs`, | ||
title: commitMessage, | ||
head: branchName, | ||
base: `master`, | ||
body: `Update changelogs of the following packages:\n\n${updatedPackages | ||
.map(p => `- ${p}`) | ||
.join(`\n`)}`, | ||
}) | ||
|
||
console.log(`\n---\n\nPR opened - ${pr.data.html_url}`) | ||
|
||
await octokit.issues.addLabels({ | ||
owner, | ||
repo, | ||
issue_number: pr.data.number, | ||
labels: [`bot: merge on green`], | ||
}) | ||
} catch (e) { | ||
console.log(e) | ||
} | ||
} |