From 48a0008c1f3af38fcea5a4d7c4269124f4b3213c Mon Sep 17 00:00:00 2001 From: Aurelio Saraiva Date: Sat, 19 Aug 2017 12:14:23 -0300 Subject: [PATCH] created deploy github-status --- .gitignore | 23 +++++++++ index.js | 46 ++++++++++++++++++ package.json | 23 +++++++++ yarn.lock | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 222 insertions(+) create mode 100644 .gitignore create mode 100644 index.js create mode 100644 package.json create mode 100644 yarn.lock diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8fa39a6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +# See https://help.github.com/ignore-files/ for more about ignoring files. + +# compiled output +/dist +/tmp + +# dependencies +/node_modules +/bower_components + +# misc +/.sass-cache +/connect.lock +/coverage/* +/libpeerconnection.log +npm-debug.log* +yarn-error.log +testem.log + +# ember-try +.node_modules.ember-try/ +bower.json.ember-try +package.json.ember-try diff --git a/index.js b/index.js new file mode 100644 index 0000000..d5e42c2 --- /dev/null +++ b/index.js @@ -0,0 +1,46 @@ +'use strict'; + +const GitHubApi = require('github'); +const DeployPluginBase = require('ember-cli-deploy-plugin'); + +module.exports = { + name: 'ember-cli-deploy-github-deployments', + createDeployPlugin(options) { + var DeployPlugin = DeployPluginBase.extend({ + name: options.name, + requiredConfig: ['publicURL', 'token', 'userOrOrganization', 'repo', 'commitSha'], + + didDeploy(context) { + return this.notifyPullRequestOfDeploy(context); + }, + + notifyPullRequestOfDeploy(context) { + let github = new GitHubApi(); + + github.authenticate({ + type: 'oauth', + token: this.readConfig('token'), + }); + + return new Promise((resolve, reject) => { + github.repos.createStatus({ + owner: this.readConfig('userOrOrganization'), + repo: this.readConfig('repo'), + sha: this.readConfig('commitSha'), + state: 'success', + target_url: this.readConfig('publicURL'), + context: 'ember-cli-deploy', + }, (error, result) => { + if (error) { + reject(error); + } else { + resolve(result); + } + }); + }); + }, + }); + + return new DeployPlugin(); + }, +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..3748ac5 --- /dev/null +++ b/package.json @@ -0,0 +1,23 @@ +{ + "name": "ember-cli-deploy-github-deployments", + "version": "0.1.0", + "description": "", + "scripts": {}, + "repository": "https://github.com/aureliosaraiva/ember-cli-deploy-github-deployments", + "engines": { + "node": ">= 4.x.x" + }, + "author": "Aurelio Saraiva", + "license": "MIT", + "keywords": [ + "ember-cli-deploy-plugin" + ], + "dependencies": { + "ember-cli-deploy-plugin": "^0.2.9", + "github": "^9.2.0", + "urlencode": "^1.1.0" + }, + "ember-addon": { + "configPath": "tests/dummy/config" + } +} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..a540a06 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,130 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +agent-base@2: + version "2.1.1" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-2.1.1.tgz#d6de10d5af6132d5bd692427d46fc538539094c7" + dependencies: + extend "~3.0.0" + semver "~5.0.1" + +ansi-regex@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" + +ansi-styles@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" + +chalk@^1.0.0, chalk@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" + dependencies: + ansi-styles "^2.2.1" + escape-string-regexp "^1.0.2" + has-ansi "^2.0.0" + strip-ansi "^3.0.0" + supports-color "^2.0.0" + +core-object@2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/core-object/-/core-object-2.0.6.tgz#60134b9c40ff69b27bc15e82db945e4df782961b" + dependencies: + chalk "^1.1.3" + +debug@2, debug@^2.2.0: + version "2.6.8" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" + dependencies: + ms "2.0.0" + +ember-cli-deploy-plugin@^0.2.9: + version "0.2.9" + resolved "https://registry.yarnpkg.com/ember-cli-deploy-plugin/-/ember-cli-deploy-plugin-0.2.9.tgz#a3d395b8adad7ef68d8bacdd0b0f4a61bcf9e651" + dependencies: + chalk "^1.0.0" + core-object "2.0.6" + lodash.clonedeep "^4.5.0" + +escape-string-regexp@^1.0.2: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + +extend@3, extend@~3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" + +follow-redirects@0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-0.0.7.tgz#34b90bab2a911aa347571da90f22bd36ecd8a919" + dependencies: + debug "^2.2.0" + stream-consume "^0.1.0" + +github@^9.2.0: + version "9.2.0" + resolved "https://registry.yarnpkg.com/github/-/github-9.2.0.tgz#8a886dc40dd63636707dcaf99df3df26c59f16fc" + dependencies: + follow-redirects "0.0.7" + https-proxy-agent "^1.0.0" + mime "^1.2.11" + netrc "^0.1.4" + +has-ansi@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" + dependencies: + ansi-regex "^2.0.0" + +https-proxy-agent@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-1.0.0.tgz#35f7da6c48ce4ddbfa264891ac593ee5ff8671e6" + dependencies: + agent-base "2" + debug "2" + extend "3" + +iconv-lite@~0.4.11: + version "0.4.18" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.18.tgz#23d8656b16aae6742ac29732ea8f0336a4789cf2" + +lodash.clonedeep@^4.5.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" + +mime@^1.2.11: + version "1.3.6" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.3.6.tgz#591d84d3653a6b0b4a3b9df8de5aa8108e72e5e0" + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + +netrc@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/netrc/-/netrc-0.1.4.tgz#6be94fcaca8d77ade0a9670dc460914c94472444" + +semver@~5.0.1: + version "5.0.3" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.0.3.tgz#77466de589cd5d3c95f138aa78bc569a3cb5d27a" + +stream-consume@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/stream-consume/-/stream-consume-0.1.0.tgz#a41ead1a6d6081ceb79f65b061901b6d8f3d1d0f" + +strip-ansi@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" + dependencies: + ansi-regex "^2.0.0" + +supports-color@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" + +urlencode@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/urlencode/-/urlencode-1.1.0.tgz#1f2ba26f013c85f0133f7a3ad6ff2730adf7cbb7" + dependencies: + iconv-lite "~0.4.11"