-
Notifications
You must be signed in to change notification settings - Fork 72
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
5 changed files
with
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const env = process.env | ||
|
||
const _ = require('lodash') | ||
const gitHelpers = require('../lib/git-helpers') | ||
|
||
module.exports = { | ||
gitUrl: env.GIT_URL, | ||
branchName: _.drop(_.split(env.GIT_BRANCH, '/')).join('/'), | ||
firstPush: gitHelpers.getNumberOfCommitsOnBranch(env.GIT_BRANCH) === 1, | ||
correctBuild: true, // assuming pull requests are not build | ||
uploadBuild: true // assuming 1 build per branch | ||
} |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#!/usr/bin/env node | ||
|
||
const exec = require('child_process').execSync | ||
const url = require('url') | ||
|
||
const config = require('./lib/config') | ||
const info = require('./ci-services')() | ||
|
@@ -32,14 +33,17 @@ module.exports = function upload () { | |
return console.error('Only uploading on one build job') | ||
} | ||
|
||
let remote = `[email protected]:${info.repoSlug}` | ||
if (info.gitUrl) remote = info.gitUrl | ||
|
||
if (env.GH_TOKEN) { | ||
// Use the GH_TOKEN if provided. | ||
exec(`git remote add gk-origin https://${env.GH_TOKEN}@github.com/${info.repoSlug}`) | ||
} else { | ||
// Otherwise, assume an SSH key is available. | ||
exec(`git remote add gk-origin [email protected]:${info.repoSlug}`) | ||
if (remote.slice(0, 5) !== 'https') remote = `https://github.com/${info.repoSlug}` | ||
const urlParsed = url.parse(remote) | ||
urlParsed.auth = env.GH_TOKEN | ||
remote = url.format(urlParsed) | ||
} | ||
|
||
exec(`git remote add gk-origin ${remote}`) | ||
exec(`git push gk-origin HEAD:${info.branchName}`) | ||
} | ||
|
||
|