From 7dcfdd647946eccc07ff55f49f3fd196a3732a6d Mon Sep 17 00:00:00 2001 From: Selby Kendrick Date: Tue, 12 Sep 2017 14:45:47 -0400 Subject: [PATCH 01/20] basic codeship support --- ci-services/codeship.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 ci-services/codeship.js diff --git a/ci-services/codeship.js b/ci-services/codeship.js new file mode 100644 index 00000000..386d735c --- /dev/null +++ b/ci-services/codeship.js @@ -0,0 +1,17 @@ +const gitHelpers = require('../lib/git-helpers') + +const env = process.env + +module.exports = { + // The GitHub repo slug + repoSlug: env.CI_REPO_NAME, + // The name of the current branch + branchName: env.CI_BRANCH, + // Is this the first push on this branch + // i.e. the Greenkeeper commit + firstPush: gitHelpers.getNumberOfCommitsOnBranch(env.CI_BRANCH) === 1, + // Is this a regular build + correctBuild: true, + // Should the lockfile be uploaded from this build + uploadBuild: true +} From af44195a8fb89f62f05afb95b298368436c10ab5 Mon Sep 17 00:00:00 2001 From: Selby Kendrick Date: Tue, 12 Sep 2017 14:53:08 -0400 Subject: [PATCH 02/20] add test for codeship --- ci-services/tests.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci-services/tests.js b/ci-services/tests.js index 65d33724..43f3ab06 100644 --- a/ci-services/tests.js +++ b/ci-services/tests.js @@ -8,5 +8,6 @@ module.exports = { jenkins: () => env.JENKINS_URL !== undefined, travis: () => env.TRAVIS === 'true', wercker: () => env.WERCKER === 'true', - bitrise: () => env.CI === 'true' && env.BITRISE_BUILD_NUMBER !== '' + bitrise: () => env.CI === 'true' && env.BITRISE_BUILD_NUMBER !== '', + codeship: () => env.CI_COMMIT_ID !== undefined } From 8942367ec8ad235d656648497cc54a65af009797 Mon Sep 17 00:00:00 2001 From: Selby Kendrick Date: Tue, 12 Sep 2017 14:55:27 -0400 Subject: [PATCH 03/20] fix bitrise false positive --- ci-services/tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci-services/tests.js b/ci-services/tests.js index 43f3ab06..9f9015d3 100644 --- a/ci-services/tests.js +++ b/ci-services/tests.js @@ -8,6 +8,6 @@ module.exports = { jenkins: () => env.JENKINS_URL !== undefined, travis: () => env.TRAVIS === 'true', wercker: () => env.WERCKER === 'true', - bitrise: () => env.CI === 'true' && env.BITRISE_BUILD_NUMBER !== '', + bitrise: () => env.CI === 'true' && env.BITRISE_BUILD_NUMBER !== undefined, codeship: () => env.CI_COMMIT_ID !== undefined } From deb6d2862c70d47e53e20ce23c28bf33bc62731f Mon Sep 17 00:00:00 2001 From: Selby Kendrick Date: Tue, 12 Sep 2017 15:19:47 -0400 Subject: [PATCH 04/20] --- ci-services/codeship.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci-services/codeship.js b/ci-services/codeship.js index 386d735c..0137e026 100644 --- a/ci-services/codeship.js +++ b/ci-services/codeship.js @@ -9,7 +9,7 @@ module.exports = { branchName: env.CI_BRANCH, // Is this the first push on this branch // i.e. the Greenkeeper commit - firstPush: gitHelpers.getNumberOfCommitsOnBranch(env.CI_BRANCH) === 1, + firstPush: gitHelpers.getNumberOfCommitsOnBranch(env.CI_BRANCH) === 1 || env.CI_BRANCH === 'greenkeeper/initial', // Is this a regular build correctBuild: true, // Should the lockfile be uploaded from this build From f4ff86b541a564805d9f73ec195e37bc603e6a61 Mon Sep 17 00:00:00 2001 From: Selby Kendrick Date: Tue, 12 Sep 2017 19:03:48 -0400 Subject: [PATCH 05/20] shouldn't run on greenkeeper/initial --- ci-services/codeship.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci-services/codeship.js b/ci-services/codeship.js index 0137e026..386d735c 100644 --- a/ci-services/codeship.js +++ b/ci-services/codeship.js @@ -9,7 +9,7 @@ module.exports = { branchName: env.CI_BRANCH, // Is this the first push on this branch // i.e. the Greenkeeper commit - firstPush: gitHelpers.getNumberOfCommitsOnBranch(env.CI_BRANCH) === 1 || env.CI_BRANCH === 'greenkeeper/initial', + firstPush: gitHelpers.getNumberOfCommitsOnBranch(env.CI_BRANCH) === 1, // Is this a regular build correctBuild: true, // Should the lockfile be uploaded from this build From 39fa9a63d9f3e944f825da3258a7e0d65f0b9d0e Mon Sep 17 00:00:00 2001 From: Selby Kendrick Date: Wed, 20 Sep 2017 17:45:14 -0400 Subject: [PATCH 06/20] better codeship test --- ci-services/tests.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci-services/tests.js b/ci-services/tests.js index 9f9015d3..c223a7da 100644 --- a/ci-services/tests.js +++ b/ci-services/tests.js @@ -8,6 +8,6 @@ module.exports = { jenkins: () => env.JENKINS_URL !== undefined, travis: () => env.TRAVIS === 'true', wercker: () => env.WERCKER === 'true', - bitrise: () => env.CI === 'true' && env.BITRISE_BUILD_NUMBER !== undefined, - codeship: () => env.CI_COMMIT_ID !== undefined + codeship: () => env.CI_NAME === 'codeship', + bitrise: () => env.CI === 'true' && env.BITRISE_BUILD_NUMBER !== '' } From 8f80578d47eae7bfebb6a102ed64a120d6c38905 Mon Sep 17 00:00:00 2001 From: Selby Kendrick Date: Wed, 20 Sep 2017 18:23:24 -0400 Subject: [PATCH 07/20] add example --- ci-services/codeship.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/ci-services/codeship.js b/ci-services/codeship.js index 386d735c..5a54d521 100644 --- a/ci-services/codeship.js +++ b/ci-services/codeship.js @@ -10,8 +10,29 @@ module.exports = { // Is this the first push on this branch // i.e. the Greenkeeper commit firstPush: gitHelpers.getNumberOfCommitsOnBranch(env.CI_BRANCH) === 1, - // Is this a regular build + // Is this a regular build (use tag: ^greenkeeper/) correctBuild: true, - // Should the lockfile be uploaded from this build + // Should the lockfile be uploaded from this build (use tag: ^greenkeeper/) uploadBuild: true } + +/* +Example `codeship-steps.yml`: +```yml +- name: "Greenkeeper: install greenkeeper-lockfile" + tag: ^greenkeeper/ + service: app + command: npm i -g greenkeeper-lockfile +- name: "Greenkeeper: update lockfile" + tag: ^greenkeeper/ + service: app + command: greenkeeper-lockfile-update +- name: Test + service: app + command: npm run codeship-test +- name: "Greenkeeper: pushing lockfile" + tag: ^greenkeeper/ + service: app + command: greenkeeper-lockfile-upload +``` +*/ From 5e076314f3936e9c272f4846d7c869a058cb8bb8 Mon Sep 17 00:00:00 2001 From: Selby Kendrick Date: Tue, 26 Sep 2017 11:30:26 -0400 Subject: [PATCH 08/20] more debug --- ci-services/codeship.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci-services/codeship.js b/ci-services/codeship.js index 5a54d521..136e505f 100644 --- a/ci-services/codeship.js +++ b/ci-services/codeship.js @@ -13,7 +13,8 @@ module.exports = { // Is this a regular build (use tag: ^greenkeeper/) correctBuild: true, // Should the lockfile be uploaded from this build (use tag: ^greenkeeper/) - uploadBuild: true + uploadBuild: true, + firstNum: gitHelpers.getNumberOfCommitsOnBranch(env.CI_BRANCH) } /* From e67655810c1b33b8b31e6ed5c01e61be7bd76f0b Mon Sep 17 00:00:00 2001 From: Selby Kendrick Date: Tue, 26 Sep 2017 11:35:04 -0400 Subject: [PATCH 09/20] always set firstPush to true --- ci-services/codeship.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ci-services/codeship.js b/ci-services/codeship.js index 136e505f..d5b17d67 100644 --- a/ci-services/codeship.js +++ b/ci-services/codeship.js @@ -9,12 +9,13 @@ module.exports = { branchName: env.CI_BRANCH, // Is this the first push on this branch // i.e. the Greenkeeper commit - firstPush: gitHelpers.getNumberOfCommitsOnBranch(env.CI_BRANCH) === 1, + firstPush: true, // Is this a regular build (use tag: ^greenkeeper/) correctBuild: true, // Should the lockfile be uploaded from this build (use tag: ^greenkeeper/) uploadBuild: true, - firstNum: gitHelpers.getNumberOfCommitsOnBranch(env.CI_BRANCH) + pushNum: gitHelpers.getNumberOfCommitsOnBranch(env.CI_BRANCH), + realFirstPush: gitHelpers.getNumberOfCommitsOnBranch(env.CI_BRANCH) === 1 } /* From b9eeeb0407a86228f1295a53d0b1a69b382af2b6 Mon Sep 17 00:00:00 2001 From: Selby Kendrick Date: Tue, 26 Sep 2017 16:53:31 -0400 Subject: [PATCH 10/20] more debug --- upload.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/upload.js b/upload.js index eebd157b..3aaa5e86 100755 --- a/upload.js +++ b/upload.js @@ -48,8 +48,9 @@ module.exports = function upload () { urlParsed.auth = env.GH_TOKEN remote = url.format(urlParsed) } - + console.log(`git remote add gk-origin ${remote}`) exec(`git remote add gk-origin ${remote}`) + console.log(`git push gk-origin HEAD:${info.branchName}`) exec(`git push gk-origin HEAD:${info.branchName}`) } From fda9658bdb99939b8e8022a51b15409ceb90274d Mon Sep 17 00:00:00 2001 From: Selby Kendrick Date: Tue, 26 Sep 2017 17:17:46 -0400 Subject: [PATCH 11/20] manual GH_ORG env var required --- ci-services/codeship.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ci-services/codeship.js b/ci-services/codeship.js index d5b17d67..8694e769 100644 --- a/ci-services/codeship.js +++ b/ci-services/codeship.js @@ -2,9 +2,19 @@ const gitHelpers = require('../lib/git-helpers') const env = process.env +function getRepoSlug() { + if(env.GH_ORG){ + console.warn('Missing GH_ORG environment variable, pushes will probably fail. ~JK ;)~') + return `${env.GH_ORG}/${env.CI_REPO_NAME}` + } else { + console.warn('Missing GH_ORG environment variable, pushes will probably fail.') + return env.CI_REPO_NAME + } +} + module.exports = { // The GitHub repo slug - repoSlug: env.CI_REPO_NAME, + repoSlug: getRepoSlug(), // The name of the current branch branchName: env.CI_BRANCH, // Is this the first push on this branch @@ -14,8 +24,8 @@ module.exports = { correctBuild: true, // Should the lockfile be uploaded from this build (use tag: ^greenkeeper/) uploadBuild: true, - pushNum: gitHelpers.getNumberOfCommitsOnBranch(env.CI_BRANCH), - realFirstPush: gitHelpers.getNumberOfCommitsOnBranch(env.CI_BRANCH) === 1 + commitNum: gitHelpers.getNumberOfCommitsOnBranch(env.CI_BRANCH), + realFirstPush: gitHelpers.getNumberOfCommitsOnBranch(env.CI_BRANCH) === 1, } /* From 3771016e4debf9206a36a2144dfda50b3aa6cc7d Mon Sep 17 00:00:00 2001 From: Selby Kendrick Date: Tue, 26 Sep 2017 17:39:40 -0400 Subject: [PATCH 12/20] extract repo slug from remote origin --- ci-services/codeship.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ci-services/codeship.js b/ci-services/codeship.js index 8694e769..70c3b9a0 100644 --- a/ci-services/codeship.js +++ b/ci-services/codeship.js @@ -1,14 +1,23 @@ +const exec = require('child_process').execSync const gitHelpers = require('../lib/git-helpers') const env = process.env function getRepoSlug() { - if(env.GH_ORG){ - console.warn('Missing GH_ORG environment variable, pushes will probably fail. ~JK ;)~') + if(env.GH_ORG) { return `${env.GH_ORG}/${env.CI_REPO_NAME}` } else { - console.warn('Missing GH_ORG environment variable, pushes will probably fail.') - return env.CI_REPO_NAME + console.info('Missing GH_ORG environment variable, extracting repoSlug from remote origin.') + let re = /github\.com[:/]([^/]+\/[^/\.]+)/g + let gitOriginUrl = exec(`git remote get-url origin`).toString() + let result = re.exec(gitOriginUrl); + if(result && result[1]) { + return result[1] + } else { + console.warn('Failed to extract repoSlug from remote origin, pushes will probably fail.') + console.warn('Set GH_ORG environment variable with your GitHub organization name.') + return env.CI_REPO_NAME + } } } From 9625377212b029737ebffe39a93a5855ca1d1bfd Mon Sep 17 00:00:00 2001 From: Selby Kendrick Date: Tue, 26 Sep 2017 17:45:53 -0400 Subject: [PATCH 13/20] try and catch some stuffs --- ci-services/codeship.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ci-services/codeship.js b/ci-services/codeship.js index 70c3b9a0..542da799 100644 --- a/ci-services/codeship.js +++ b/ci-services/codeship.js @@ -9,11 +9,12 @@ function getRepoSlug() { } else { console.info('Missing GH_ORG environment variable, extracting repoSlug from remote origin.') let re = /github\.com[:/]([^/]+\/[^/\.]+)/g - let gitOriginUrl = exec(`git remote get-url origin`).toString() - let result = re.exec(gitOriginUrl); - if(result && result[1]) { + let result; + try { + let gitOriginUrl = exec(`git remote get-url origin`).toString() + result = re.exec(gitOriginUrl); return result[1] - } else { + } catch(e) { console.warn('Failed to extract repoSlug from remote origin, pushes will probably fail.') console.warn('Set GH_ORG environment variable with your GitHub organization name.') return env.CI_REPO_NAME From 2a8033d3ddd4380b373d8c4b97413ba65323b82d Mon Sep 17 00:00:00 2001 From: Selby Kendrick Date: Tue, 26 Sep 2017 18:15:31 -0400 Subject: [PATCH 14/20] try to get repoSlug from package.json --- ci-services/codeship.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/ci-services/codeship.js b/ci-services/codeship.js index 542da799..19d409e3 100644 --- a/ci-services/codeship.js +++ b/ci-services/codeship.js @@ -1,24 +1,25 @@ -const exec = require('child_process').execSync +const relative = require('require-relative') const gitHelpers = require('../lib/git-helpers') const env = process.env +const pkg = relative('./package.json') function getRepoSlug() { if(env.GH_ORG) { return `${env.GH_ORG}/${env.CI_REPO_NAME}` } else { - console.info('Missing GH_ORG environment variable, extracting repoSlug from remote origin.') + console.info('Missing GH_ORG environment variable, extracting repoSlug from package.json') let re = /github\.com[:/]([^/]+\/[^/\.]+)/g - let result; - try { - let gitOriginUrl = exec(`git remote get-url origin`).toString() - result = re.exec(gitOriginUrl); - return result[1] - } catch(e) { - console.warn('Failed to extract repoSlug from remote origin, pushes will probably fail.') - console.warn('Set GH_ORG environment variable with your GitHub organization name.') - return env.CI_REPO_NAME + let result + if(pkg.repository.url){ + result = re.exec(pkg.repository.url) + if(result && result[1]) { + return result[1] + } } + console.warn('Failed to extract repoSlug from package.json, pushes will probably fail.') + console.warn('Set repository.url with the repo GitHub url in package.json.') + return env.CI_REPO_NAME } } From ed22d62a391593da9d5c803d315e7532eb6bc33e Mon Sep 17 00:00:00 2001 From: Selby Kendrick Date: Tue, 26 Sep 2017 18:48:46 -0400 Subject: [PATCH 15/20] should update on commit message regex --- ci-services/codeship.js | 13 +++++++++---- upload.js | 3 +-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ci-services/codeship.js b/ci-services/codeship.js index 19d409e3..8b7814fd 100644 --- a/ci-services/codeship.js +++ b/ci-services/codeship.js @@ -23,6 +23,11 @@ function getRepoSlug() { } } +function shouldUpdate() { + let re = /^chore\(package\): update [^ ]+ to version .*$/mi + return re.test(env.CI_COMMIT_MESSAGE) +} + module.exports = { // The GitHub repo slug repoSlug: getRepoSlug(), @@ -30,13 +35,13 @@ module.exports = { branchName: env.CI_BRANCH, // Is this the first push on this branch // i.e. the Greenkeeper commit - firstPush: true, + firstPush: shouldUpdate(), // Is this a regular build (use tag: ^greenkeeper/) - correctBuild: true, + correctBuild: shouldUpdate(), // Should the lockfile be uploaded from this build (use tag: ^greenkeeper/) - uploadBuild: true, + uploadBuild: shouldUpdate(), commitNum: gitHelpers.getNumberOfCommitsOnBranch(env.CI_BRANCH), - realFirstPush: gitHelpers.getNumberOfCommitsOnBranch(env.CI_BRANCH) === 1, + realFirstPush: gitHelpers.getNumberOfCommitsOnBranch(env.CI_BRANCH) === 1 } /* diff --git a/upload.js b/upload.js index 3aaa5e86..9b83f521 100755 --- a/upload.js +++ b/upload.js @@ -48,9 +48,8 @@ module.exports = function upload () { urlParsed.auth = env.GH_TOKEN remote = url.format(urlParsed) } - console.log(`git remote add gk-origin ${remote}`) + exec(`git remote add gk-origin ${remote}`) - console.log(`git push gk-origin HEAD:${info.branchName}`) exec(`git push gk-origin HEAD:${info.branchName}`) } From 42c77119d8209036a9f92a215f69a80664496240 Mon Sep 17 00:00:00 2001 From: Selby Kendrick Date: Fri, 29 Sep 2017 16:56:51 -0400 Subject: [PATCH 16/20] could be chore or fix --- ci-services/codeship.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci-services/codeship.js b/ci-services/codeship.js index 8b7814fd..220f5180 100644 --- a/ci-services/codeship.js +++ b/ci-services/codeship.js @@ -24,7 +24,7 @@ function getRepoSlug() { } function shouldUpdate() { - let re = /^chore\(package\): update [^ ]+ to version .*$/mi + let re = /^(chore|fix)\(package\): update [^ ]+ to version.*$/mi return re.test(env.CI_COMMIT_MESSAGE) } From 0d0e14699ab5a223a32eeb3fc7375d0e08fe2870 Mon Sep 17 00:00:00 2001 From: Selby Kendrick Date: Wed, 4 Oct 2017 20:42:08 -0400 Subject: [PATCH 17/20] add docs --- ci-services/codeship.js | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/ci-services/codeship.js b/ci-services/codeship.js index 220f5180..baebb413 100644 --- a/ci-services/codeship.js +++ b/ci-services/codeship.js @@ -4,16 +4,19 @@ const gitHelpers = require('../lib/git-helpers') const env = process.env const pkg = relative('./package.json') +/** + * Generates repoSlug from user set `GH_ORG` env var and Codeship set + * `CI_REPO_NAME`. Fails back to extracting from `package.json`.repository.url + */ function getRepoSlug() { - if(env.GH_ORG) { + if (env.GH_ORG) { return `${env.GH_ORG}/${env.CI_REPO_NAME}` } else { - console.info('Missing GH_ORG environment variable, extracting repoSlug from package.json') let re = /github\.com[:/]([^/]+\/[^/\.]+)/g let result - if(pkg.repository.url){ + if (pkg.repository.url) { result = re.exec(pkg.repository.url) - if(result && result[1]) { + if (result && result[1]) { return result[1] } } @@ -23,6 +26,9 @@ function getRepoSlug() { } } +/** + * Should update the `package-lock.json` + */ function shouldUpdate() { let re = /^(chore|fix)\(package\): update [^ ]+ to version.*$/mi return re.test(env.CI_COMMIT_MESSAGE) @@ -63,4 +69,24 @@ Example `codeship-steps.yml`: service: app command: greenkeeper-lockfile-upload ``` + +`repository` key in `package.json` or GH_ORG with the org name is required, as there's no way to +get it from the ENV vars that Codeship sets. +`package.json`: +``` +{ + ... + "repository": { + "type": "git", + "url": "https://github.com/org/repo.git" + }, + ... +} +``` + +Might need this in your `dockerfile` for ssh pushes: +``` +RUN mkdir -p ~/.ssh +RUN echo "github ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~/.ssh/known_hosts +``` */ From fc89c7cc96bb36e2f9319458bd273e429b310787 Mon Sep 17 00:00:00 2001 From: Selby Kendrick Date: Tue, 10 Oct 2017 14:07:14 -0400 Subject: [PATCH 18/20] fix linting errors --- ci-services/codeship.js | 6 +++--- upload.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ci-services/codeship.js b/ci-services/codeship.js index baebb413..bb825f1b 100644 --- a/ci-services/codeship.js +++ b/ci-services/codeship.js @@ -8,11 +8,11 @@ const pkg = relative('./package.json') * Generates repoSlug from user set `GH_ORG` env var and Codeship set * `CI_REPO_NAME`. Fails back to extracting from `package.json`.repository.url */ -function getRepoSlug() { +function getRepoSlug () { if (env.GH_ORG) { return `${env.GH_ORG}/${env.CI_REPO_NAME}` } else { - let re = /github\.com[:/]([^/]+\/[^/\.]+)/g + let re = /github\.com[:/]([^/]+\/[^/\.]+)/g // eslint-disable-line no-useless-escape let result if (pkg.repository.url) { result = re.exec(pkg.repository.url) @@ -29,7 +29,7 @@ function getRepoSlug() { /** * Should update the `package-lock.json` */ -function shouldUpdate() { +function shouldUpdate () { let re = /^(chore|fix)\(package\): update [^ ]+ to version.*$/mi return re.test(env.CI_COMMIT_MESSAGE) } diff --git a/upload.js b/upload.js index 9b83f521..eebd157b 100755 --- a/upload.js +++ b/upload.js @@ -48,7 +48,7 @@ module.exports = function upload () { urlParsed.auth = env.GH_TOKEN remote = url.format(urlParsed) } - + exec(`git remote add gk-origin ${remote}`) exec(`git push gk-origin HEAD:${info.branchName}`) } From 302eebf2480185a04fbf45ec812c806925915741 Mon Sep 17 00:00:00 2001 From: Selby Kendrick Date: Tue, 19 Dec 2017 15:55:55 -0500 Subject: [PATCH 19/20] work with string repositories too --- ci-services/codeship.js | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/ci-services/codeship.js b/ci-services/codeship.js index bb825f1b..d030ab3d 100644 --- a/ci-services/codeship.js +++ b/ci-services/codeship.js @@ -11,19 +11,20 @@ const pkg = relative('./package.json') function getRepoSlug () { if (env.GH_ORG) { return `${env.GH_ORG}/${env.CI_REPO_NAME}` - } else { - let re = /github\.com[:/]([^/]+\/[^/\.]+)/g // eslint-disable-line no-useless-escape - let result - if (pkg.repository.url) { - result = re.exec(pkg.repository.url) - if (result && result[1]) { - return result[1] - } - } - console.warn('Failed to extract repoSlug from package.json, pushes will probably fail.') - console.warn('Set repository.url with the repo GitHub url in package.json.') - return env.CI_REPO_NAME } + let re = /github\.com[:/]([^/]+\/[^/\.]+)/g // eslint-disable-line no-useless-escape + let result + if (typeof pkg.repository === 'string') { + result = re.exec(pkg.repository) + } else if (typeof pkg.repository.url === 'string') { + result = re.exec(pkg.repository.url) + } + if (result && result[1]) { + return result[1] + } + console.warn('Failed to extract repoSlug from package.json, pushes will probably fail.') + console.warn('Set repository.url with the repo GitHub url in package.json.') + return env.CI_REPO_NAME } /** @@ -83,10 +84,4 @@ get it from the ENV vars that Codeship sets. ... } ``` - -Might need this in your `dockerfile` for ssh pushes: -``` -RUN mkdir -p ~/.ssh -RUN echo "github ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~/.ssh/known_hosts -``` */ From f85ef414a24e13d29d68cb73324246dd578dee72 Mon Sep 17 00:00:00 2001 From: Selby Kendrick Date: Wed, 20 Dec 2017 12:16:11 -0500 Subject: [PATCH 20/20] example with just a repo string --- ci-services/codeship.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ci-services/codeship.js b/ci-services/codeship.js index d030ab3d..2a3271d5 100644 --- a/ci-services/codeship.js +++ b/ci-services/codeship.js @@ -75,6 +75,14 @@ Example `codeship-steps.yml`: get it from the ENV vars that Codeship sets. `package.json`: ``` +{ + ... + "repository": "https://github.com/org/repo.git" + }, + ... +} +``` +``` { ... "repository": {