Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update readme and add some w.i.p. stuff.

  • Loading branch information...
commit 47a187f3b03cba2c9b4861bb4a7512008967fbcf 1 parent cc82491
@Kami Kami authored
View
23 README.md
@@ -12,6 +12,29 @@ the Cast plugin API.
...
+## Example settings
+
+"github": {
+ "username": "your_github_username",
+ "api_key": "apikey12345",
+
+ "projects": {
+ "project_name_1": {
+ "filters": {
+ "tag": "v.+?",
+ "branch": ""
+ }
+ },
+
+ "project_name_2": {
+ "filters": {
+ "tag": "",
+ "branch": "production"
+ }
+ }
+ }
+}
+
## Notes
For now you need to bundle all the dependencies with your plugin. In the future
View
40 lib/core.js
@@ -0,0 +1,40 @@
+/**
+ * Check if change matches any filters.
+ *
+ * @return {String} true if change matches a filter, false otherwise.
+ */
+
+function changeMatchesFilter(change) {
+ var i, len, filters, filter;
+ var filterTag, filterBranch, tag, branch;
+ for (i = 0, len = filters.length; i < len; i++) {
+ filter = filters[i];
+ filterTag = new RegExp(filter.tag);
+ filterBranch = new RegExp(filter.branch);
+ tag = null;
+ branch = null;
+
+ if (filterTag && filterTag.test(tag)) {
+ return true;
+ }
+ else if (filterBranch && filterBranch.test(branch)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+function handlePayload(payload) {
+ var i, len, changes, change;
+
+ for (i = 0, len = payload.length; i < len; i++) {
+ change = payload[i];
+
+ if (changeMatchesFilter(change)) {
+ // @TODO: Enqueue a job for the application deployment
+ }
+ }
+}
+
+exports.handlePayload = handlePayload;
View
27 lib/http/endpoints/webhook.js
@@ -0,0 +1,27 @@
+var log = require('cast/util/lib');
+
+function handlePayload(req, res) {
+ // @TODO
+ var payload, parsed;
+ payload = req.params.payload;
+
+ try {
+ parsed = JSON.parse(payload);
+ }
+ catch (err) {
+ log.error('Failed to parse payload: %s', err);
+ res.writeHead(500, {});
+ res.end();
+ return;
+ }
+
+ res.writeHead(200, {});
+ res.end();
+}
+
+var routes = [
+ // 'method', 'path', middleware1, middleware2, ..., handler
+ ['GET', '/webhook', handlePayload]
+];
+
+exports.routes = routes;
View
2  lib/validators.js
@@ -0,0 +1,2 @@
+function isValidMapping(projects) {
+}
View
8 package.json
@@ -27,8 +27,9 @@
"main": "",
"bin": {},
- "services": [],
"agent_version": ">= 0.1.0",
+ "services": [],
+ "jobs": [],
"settings": {
"username": {
"type": "string"
@@ -36,8 +37,9 @@
"api_token": {
"type": "string"
},
- "project_names": {
- "type": "array"
+ "projects": {
+ "type": "object",
+ "validator": "is_valid_mapping"
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.