Skip to content

Commit

Permalink
feat: build for release
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Mar 29, 2021
1 parent 507c988 commit c174aac
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 44 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ input and not read from the environment, since this prevents unnecessary builds

## Inputs

| Name | Requirement | Default | Description |
| --------------------------- | ----------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `target-repo` | _required_ | | Repository which should be build by mybinder.org . |
| `service-name` | _required_ | `'gh'` | gh \| gist \| gl \| git \| zenodo \| figshare Name of the service that hosts the repo. |
| `target-state` | _optional_ | `'master'` | Name of the branch, tag or commit which should be build, by mybinder.org. |
| `use-default-build-servers` | _optional_ | `true` | Whether or not to use the default mybinder.org build servers. If false and additional-build-server is not specified, this will throw an error. |
| `additional-build-servers` | _optional_ | `''` | Newline separated list of urls, which point do binder build servers base url. |
| `debug` | _optional_ | `false` | If this is true all server response messages will be printed to console. |
| Name | Requirement | Default | Description |
| --------------------------- | ----------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `target-repo` | _required_ | | Repository which should be build by mybinder.org . |
| `service-name` | _required_ | `'gh'` | gh \| gist \| gl \| git \| zenodo \| figshare Name of the service that hosts the repo. |
| `target-state` | _optional_ | `''` | Name of the branch, tag or commit which should be build, by mybinder.org. |
| `use-default-build-servers` | _optional_ | `true` | Whether or not to use the default mybinder.org build servers. If false and additional-build-server is not specified, this will throw an error. |
| `additional-build-servers` | _optional_ | `''` | Newline separated list of urls, which point do binder build servers base url. |
| `debug` | _optional_ | `false` | If this is true all server response messages will be printed to console. |

## Usage

Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ inputs:
required: false
default: gh
target-state:
description: "Name of the branch, tag or commit which should be build. Default: 'master'"
description: "Name of the branch, tag or commit which should be build. Default: ''"
required: false
default: 'master'
default: ''
use-default-build-servers:
description: 'Whether or not to use the default mybinder.org build servers. If false and additional-build-server is not specified, this will throw an error. Default: true'
required: false
Expand Down
2 changes: 1 addition & 1 deletion build.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"owner":"s-weigand","repo":"trigger-mybinder-build","sha":"8d1552d1ee5f8042962cf67b9b97d104a0fae7cb","ref":"refs/tags/v1.0.4","tagName":"v1.0.4","branch":"release","tags":["v1.0.4","v1"],"updated_at":"2020-10-01T18:10:54.861Z"}
{"owner":"s-weigand","repo":"trigger-mybinder-build","sha":"5750828b5ebede9cd27b4c64b8f02dc743d09e15","ref":"refs/tags/v1.1.0","tagName":"v1.1.0","branch":"release","tags":["v1.1.0","v1"],"updated_at":"2021-03-29T16:34:04.835Z"}
137 changes: 104 additions & 33 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ module.exports =
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ var threw = true;
/******/ try {
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete installedModules[moduleId];
/******/ }
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
Expand Down Expand Up @@ -117,26 +123,39 @@ exports.issueCommand = issueCommand;

"use strict";

var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(__webpack_require__(470));
const load_config_1 = __webpack_require__(477);
const request_trigger_1 = __webpack_require__(830);
const run = () => __awaiter(this, void 0, void 0, function* () {
const run = () => __awaiter(void 0, void 0, void 0, function* () {
try {
const config = load_config_1.loadConfig();
request_trigger_1.triggerBuilds(config);
Expand Down Expand Up @@ -201,6 +220,7 @@ function EventSource (url, eventSourceInitDict) {

var self = this
self.reconnectInterval = 1000
self.connectionInProgress = false

function onConnectionClosed (message) {
if (readyState === EventSource.CLOSED) return
Expand All @@ -214,9 +234,10 @@ function EventSource (url, eventSourceInitDict) {
reconnectUrl = null
}
setTimeout(function () {
if (readyState !== EventSource.CONNECTING) {
if (readyState !== EventSource.CONNECTING || self.connectionInProgress) {
return
}
self.connectionInProgress = true
connect()
}, self.reconnectInterval)
}
Expand Down Expand Up @@ -252,6 +273,10 @@ function EventSource (url, eventSourceInitDict) {
// but for now exists as a backwards-compatibility layer
options.rejectUnauthorized = !(eventSourceInitDict && !eventSourceInitDict.rejectUnauthorized)

if (eventSourceInitDict && eventSourceInitDict.createConnection !== undefined) {
options.createConnection = eventSourceInitDict.createConnection
}

// If specify http proxy, make the request to sent to the proxy server,
// and include the original url in path and Host headers
var useProxy = eventSourceInitDict && eventSourceInitDict.proxy
Expand Down Expand Up @@ -287,6 +312,7 @@ function EventSource (url, eventSourceInitDict) {
}

req = (isSecure ? https : http).request(options, function (res) {
self.connectionInProgress = false
// Handle HTTP errors
if (res.statusCode === 500 || res.statusCode === 502 || res.statusCode === 503 || res.statusCode === 504) {
_emit('error', new Event('error', {status: res.statusCode, message: res.statusMessage}))
Expand All @@ -295,7 +321,7 @@ function EventSource (url, eventSourceInitDict) {
}

// Handle HTTP redirects
if (res.statusCode === 301 || res.statusCode === 307) {
if (res.statusCode === 301 || res.statusCode === 302 || res.statusCode === 307) {
if (!res.headers.location) {
// Server sent redirect response without Location header.
_emit('error', new Event('error', {status: res.statusCode, message: res.statusMessage}))
Expand Down Expand Up @@ -330,6 +356,8 @@ function EventSource (url, eventSourceInitDict) {
// Source/WebCore/page/EventSource.cpp
var isFirst = true
var buf
var startingPos = 0
var startingFieldLength = -1
res.on('data', function (chunk) {
buf = buf ? Buffer.concat([buf, chunk]) : chunk
if (isFirst && hasBom(buf)) {
Expand All @@ -349,10 +377,10 @@ function EventSource (url, eventSourceInitDict) {
}

var lineLength = -1
var fieldLength = -1
var fieldLength = startingFieldLength
var c

for (var i = pos; lineLength < 0 && i < length; ++i) {
for (var i = startingPos; lineLength < 0 && i < length; ++i) {
c = buf[i]
if (c === colon) {
if (fieldLength < 0) {
Expand All @@ -367,7 +395,12 @@ function EventSource (url, eventSourceInitDict) {
}

if (lineLength < 0) {
startingPos = length - pos
startingFieldLength = fieldLength
break
} else {
startingPos = 0
startingFieldLength = -1
}

parseEventStreamLine(buf, pos, fieldLength, lineLength)
Expand All @@ -384,6 +417,7 @@ function EventSource (url, eventSourceInitDict) {
})

req.on('error', function (err) {
self.connectionInProgress = false
onConnectionClosed(err.message)
})

Expand Down Expand Up @@ -743,8 +777,8 @@ module.exports = origin;

var required = __webpack_require__(869)
, qs = __webpack_require__(521)
, slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//
, protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i
, slashes = /^[A-Za-z][A-Za-z0-9+-.]*:[\\/]+/
, protocolre = /^([a-z][a-z0-9.+-]*:)?([\\/]{1,})?([\S\s]*)/i
, whitespace = '[\\x09\\x0A\\x0B\\x0C\\x0D\\x20\\xA0\\u1680\\u180E\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000\\u2028\\u2029\\uFEFF]'
, left = new RegExp('^'+ whitespace +'+');

Expand Down Expand Up @@ -856,12 +890,16 @@ function lolcation(loc) {
*/
function extractProtocol(address) {
address = trimLeft(address);
var match = protocolre.exec(address);

var match = protocolre.exec(address)
, protocol = match[1] ? match[1].toLowerCase() : ''
, slashes = !!(match[2] && match[2].length >= 2)
, rest = match[2] && match[2].length === 1 ? '/' + match[3] : match[3];

return {
protocol: match[1] ? match[1].toLowerCase() : '',
slashes: !!match[2],
rest: match[3]
protocol: protocol,
slashes: slashes,
rest: rest
};
}

Expand Down Expand Up @@ -1021,6 +1059,14 @@ function Url(address, location, parser) {
url.pathname = resolve(url.pathname, location.pathname);
}

//
// Default to a / for pathname if none exists. This normalizes the URL
// to always have a /
//
if (url.pathname.charAt(0) !== '/' && url.hostname) {
url.pathname = '/' + url.pathname;
}

//
// We should not add port numbers if they are already the default port number
// for a given protocol. As the host also contains the port number we're going
Expand Down Expand Up @@ -1443,14 +1489,27 @@ exports.getState = getState;

"use strict";

var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.validServiceName = exports.validateConfig = exports.loadConfig = void 0;
const core = __importStar(__webpack_require__(470));
const serviceNames = ['gh', 'gist', 'gl', 'git', 'zenodo', 'figshare'];
exports.loadConfig = () => {
Expand All @@ -1463,8 +1522,8 @@ exports.loadConfig = () => {
const additionalBuildServers = core
.getInput('additional-build-servers')
.split('\n')
.map(additionalBuildServer => additionalBuildServer.trim())
.filter(additionalBuildServer => additionalBuildServer !== '');
.map((additionalBuildServer) => additionalBuildServer.trim())
.filter((additionalBuildServer) => additionalBuildServer !== '');
const debug = core.getInput('debug') === 'true';
const config = {
targetRepo,
Expand Down Expand Up @@ -1558,7 +1617,7 @@ function encode(input) {
* @api public
*/
function querystring(query) {
var parser = /([^=?&]+)=?([^&]*)/g
var parser = /([^=?#&]+)=?([^&]*)/g
, result = {}
, part;

Expand Down Expand Up @@ -1613,8 +1672,8 @@ function querystringify(obj, prefix) {
value = '';
}

key = encodeURIComponent(key);
value = encodeURIComponent(value);
key = encode(key);
value = encode(value);

//
// If we failed to encode the strings, we should bail out as we don't
Expand Down Expand Up @@ -1677,17 +1736,30 @@ module.exports = require("fs");

"use strict";

var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.triggerBuilds = exports.requestBuild = void 0;
const core = __importStar(__webpack_require__(470));
const eventsource_1 = __importDefault(__webpack_require__(136));
exports.requestBuild = (url, debug) => {
Expand Down Expand Up @@ -1726,8 +1798,7 @@ exports.requestBuild = (url, debug) => {
// fail save in case there are no messages and no errors
setTimeout(() => {
source.close();
reject(`Request Error ${url}\nConnection timed out, via fail save after ${maxTimeOut /
1000}s.`);
reject(`Request Error ${url}\nConnection timed out, via fail save after ${maxTimeOut / 1000}s.`);
}, maxTimeOut);
});
};
Expand Down Expand Up @@ -1767,13 +1838,13 @@ exports.triggerBuilds = (config) => {
}
responses.push(exports.requestBuild(url, config.debug)
.then(() => true)
.catch(reason => {
.catch((reason) => {
core.error(`Error for ${url}:\n${reason}\n`);
return false;
}));
}
// tslint:disable-next-line no-floating-promises
Promise.all(responses).then(values => {
Promise.all(responses).then((values) => {
if (values.indexOf(true) === -1) {
throw new Error('All requests to build the binder image have failed.');
}
Expand Down

0 comments on commit c174aac

Please sign in to comment.