Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerhub automated build integration #866 #888

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,14 @@ <h3 id="build"> Build </h3>
<td><img src='https://img.shields.io/sensiolabs/i/45afb680-d4e6-4e66-93ea-bcfa79eb8a87.svg?maxAge=2592000' alt=''/></td>
<td><code>https://img.shields.io/sensiolabs/i/45afb680-d4e6-4e66-93ea-bcfa79eb8a87.svg</code></td>
</tr>
<tr><th data-keywords='docker automated build status'> Docker Automated build status</th>
<td><img src='https://img.shields.io/docker/build/mariobehling/loklak.svg?maxAge=2592000' alt=''/></td>
<td><code>https://img.shields.io/docker/build/mariobehling/loklak.svg</code></td>
</tr>
<tr><th data-keywords='docker automated build status'> Docker Automated build status with tag</th>
<td><img src='https://img.shields.io/docker/build/mariobehling/loklak:development.svg?maxAge=2592000' alt=''/></td>
<td><code>https://img.shields.io/docker/build/mariobehling/loklak:development.svg</code></td>
</tr>
</tbody></table>
<h3 id="downloads"> Downloads </h3>
<table class='badge'><tbody>
Expand Down
57 changes: 57 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5036,6 +5036,63 @@ cache(function(data, match, sendBadge, request) {
});
}));

// Docker Hub automated build integration.
camp.route(/^\/docker\/build\/([^\/]+)\/([^\/:]+?)(:([^\/]+?))?\.(svg|png|gif|jpg|json)$/,
cache(function(data, match, sendBadge, request) {
var user = match[1];
var repo = match[2];
var format = match[5];
var tag = match[4] || "latest";
var path = user + '/' + repo;
var url = 'https://hub.docker.com/v2/repositories/' + path + '/buildhistory/?page_size=100'
var badgeData = getBadgeData('docker build', data);
function apiRequest(err, res, buffer) {
if (err != null) {
badgeData.text[1] = 'inaccessible';
sendBadge(format, badgeData);
return;
}
try {
var data = JSON.parse(buffer);
var results = data.results;
if (!results) {
// repository does not exist
badgeData.text[1] = path + ' not found';
sendBadge(format, badgeData);
return;
}
for (var i = 0; i < results.length; i += 1) {
var build = results[i];
if (build.dockertag_name == tag) {
if (build.status < 0) {
badgeData.text[1] = 'Error';
badgeData.colorB = '#ff992e'; // dockerhub color
} else {
badgeData.text[1] = 'Success';
badgeData.colorB = '#86d800'; // dockerhub color
}
sendBadge(format, badgeData);
return;
}
}
if (data.next) {
// we can search more to find the tag
request(data.next, apiRequest);
} else {
// tag not found
badgeData.text[1] = 'no tag ' + tag;
sendBadge(format, badgeData);
return;
}
} catch(e) {
badgeData.text[1] = 'invalid';
sendBadge(format, badgeData);
return;
}
}
request(url, apiRequest);
}));

// Twitter integration.
camp.route(/^\/twitter\/url\/([^\/]+)\/(.+)\.(svg|png|gif|jpg|json)$/,
cache(function(data, match, sendBadge, request) {
Expand Down
8 changes: 8 additions & 0 deletions try.html
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,14 @@ <h3 id="build"> Build </h3>
<td><img src='/sensiolabs/i/45afb680-d4e6-4e66-93ea-bcfa79eb8a87.svg' alt=''/></td>
<td><code>https://img.shields.io/sensiolabs/i/45afb680-d4e6-4e66-93ea-bcfa79eb8a87.svg</code></td>
</tr>
<tr><th data-keywords='docker automated build status'> Docker Automated build status</th>
<td><img src='/docker/build/mariobehling/loklak.svg' alt=''/></td>
<td><code>https://img.shields.io/docker/build/mariobehling/loklak.svg</code></td>
</tr>
<tr><th data-keywords='docker automated build status'> Docker Automated build status with tag</th>
<td><img src='/docker/build/mariobehling/loklak:development.svg' alt=''/></td>
<td><code>https://img.shields.io/docker/build/mariobehling/loklak:development.svg</code></td>
</tr>
</tbody></table>
<h3 id="downloads"> Downloads </h3>
<table class='badge'><tbody>
Expand Down