Last active
October 1, 2020 01:57
-
-
Save dereckson/23181a751e014796c52a4011e2a7de22 to your computer and use it in GitHub Desktop.
Regenerate DockerHubBuildTriggers.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
triggers = {}; | |
(function () { | |
var s = document.createElement('script'); | |
s.setAttribute('src', 'https://code.jquery.com/jquery-3.5.1.min.js'); | |
document.body.appendChild(s); | |
}()); | |
// Pause as we need jQuery object to be available, and so we need to let time to the browser to load the script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.getJSON("https://hub.docker.com/v2/repositories/nasqueron/?page_size=100", function (response) { | |
for (result of response["results"]) { | |
image = result["namespace"] + "%2F" + result["name"]; | |
jQuery.ajax({ | |
url: "https://hub.docker.com/api/build/v1/nasqueron/source/?image=" + image, | |
context: {image: image.replace("%2F", "/")} | |
}).done(function (response) { | |
object = response["objects"][0] | |
if (object) { | |
jQuery.ajax({ | |
url: "https://hub.docker.com/api/build/v1/nasqueron/source/" + object["uuid"] + "/trigger/", | |
context: {image: object["image"]} | |
}).done(function (response) { | |
triggers[this["image"]] = response["objects"][0]["url"] | |
}); | |
} else { | |
console.warn("No automated build for " + this["image"]) | |
} | |
}) | |
} | |
}); | |
// Pause to let some time to the requests to be processed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We've got a winner :) | |
console.log(JSON.stringify(triggers)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This procedure allows to fetch the trigger build URL for each automated build repo.
The final object is a JSON document we can publish to /srv/notifications/storage/app/DockerHubBuildTriggers.js