Skip to content

Commit

Permalink
Merge pull request #80 from hanachin/docker-hub-automated-build
Browse files Browse the repository at this point in the history
Add Docker Hub automated build hook
  • Loading branch information
hibariya committed Jun 8, 2017
2 parents 64d6ed9 + f617556 commit 0736a43
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/hooks/docker-hub/help.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
%dl
%dt Usage
%dd
See <a href="https://docs.docker.com/docker-hub/webhooks/" target="_blank">Webhooks for automated builds | Docker Documentation</a>.
6 changes: 6 additions & 0 deletions lib/hooks/docker-hub/hook.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Idobata::Hook
class DockerHub < Base
screen_name 'Docker Hub'
icon_url hook_image_url('mono_vertical_small_resized.png')
end
end
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions lib/hooks/docker-hub/templates/default.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
%div
#{payload.push_data.pusher} pushed <a href="#{payload.repository.repo_url}">#{payload.repository.repo_name}</a>:#{payload.push_data.tag}
18 changes: 18 additions & 0 deletions spec/docker_hub_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
describe Idobata::Hook::DockerHub, type: :hook do
let(:payload) { fixture_payload('docker_hub.json') }

before do
post payload, 'Content-Type' => 'application/json'
end

describe '#process_payload' do
subject { hook.process_payload }

its([:source]) { should eq(<<-HTML.strip_heredoc) }
<div>
hanachin pushed <a href="https://hub.docker.com/r/hanachin/tmp_docker_hub_webhook">hanachin/tmp_docker_hub_webhook</a>:latest
</div>
HTML
its([:format]) { should eq(:html) }
end
end
1 change: 1 addition & 0 deletions spec/fixtures/payload/docker_hub.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"push_data": {"pushed_at": 1496850959, "images": [], "tag": "latest", "pusher": "hanachin"}, "callback_url": "https://registry.hub.docker.com/u/hanachin/tmp_docker_hub_webhook/hook/2111hfhgcfee04ca5cefbcjbg115c5f42/", "repository": {"status": "Active", "description": "the image to confirm webhook", "is_trusted": true, "full_description": null, "repo_url": "https://hub.docker.com/r/hanachin/tmp_docker_hub_webhook", "owner": "hanachin", "is_official": false, "is_private": false, "name": "tmp_docker_hub_webhook", "namespace": "hanachin", "star_count": 0, "comment_count": 0, "date_created": 1496582049, "dockerfile": "FROM alpine\n\nRUN echo hi\n", "repo_name": "hanachin/tmp_docker_hub_webhook"}}

0 comments on commit 0736a43

Please sign in to comment.