Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* build: auto-push patch file changes * chore: change patch for testing purposes * build: remove stray log * build: push as electron bot * build: suppress all output of the push-patch script * chore: fix linting
- Loading branch information
1 parent
7feffc7
commit d94a5dd
Showing
4 changed files
with
250 additions
and
9 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
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,41 @@ | ||
const { createAppAuth } = require('@octokit/auth-app'); | ||
const cp = require('child_process'); | ||
|
||
if (!process.env.CIRCLE_BRANCH) { | ||
console.error('Not building for a specific branch, can\'t autopush a patch'); | ||
process.exit(1); | ||
} | ||
|
||
if (process.env.CIRCLE_PR_NUMBER) { | ||
console.error('Building for a forked PR, can\'t autopush a patch'); | ||
process.exit(1); | ||
} | ||
|
||
const auth = createAppAuth({ | ||
appId: process.env.PATCH_UP_APP_ID, | ||
privateKey: Buffer.from(process.env.PATCH_UP_PRIVATE_KEY, 'base64').toString('utf8'), | ||
installationId: process.env.PATCH_UP_INSTALLATION_ID, | ||
clientId: process.env.PATCH_UP_CLIENT_ID, | ||
clientSecret: process.env.PATCH_UP_CLIENT_SECRET | ||
}); | ||
|
||
async function main () { | ||
const installationAuth = await auth({ type: 'installation' }); | ||
const remoteURL = `https://x-access-token:${installationAuth.token}@github.com/electron/electron.git`; | ||
// NEVER LOG THE OUTPUT OF THIS COMMAND | ||
// GIT LEAKS THE ACCESS CREDENTIALS IN CONSOLE LOGS | ||
const { status } = cp.spawnSync('git', ['push', '--set-upstream', remoteURL], { | ||
stdio: 'ignore' | ||
}); | ||
if (status !== 0) { | ||
console.error('Failed to push to target branch'); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
if (process.mainModule === module) { | ||
main().catch((err) => { | ||
console.error(err); | ||
process.exit(1); | ||
}); | ||
} |
Oops, something went wrong.