diff options
author | Elvin Efendi <elvin.efendiyev@gmail.com> | 2015-11-16 13:13:08 -0500 |
---|---|---|
committer | Elvin Efendi <elvin.efendiyev@gmail.com> | 2015-11-16 13:13:08 -0500 |
commit | 937b1f6806caf8f4e0b4397398770ac4e339cdb4 (patch) | |
tree | 669ff5b2daed2951db23d5fb5079f7dc6d6039f2 /lib/oxidized | |
parent | 5a2364e50620b825d5325bfbbc5d0f3d8578e25f (diff) | |
parent | 817f33a2a1e8f78720f5e73a10ee45384e886ae9 (diff) |
Merge pull request #1 from Shopify/github-hook
a callback to push config changes to a remote repository
Diffstat (limited to 'lib/oxidized')
-rw-r--r-- | lib/oxidized/hook/githubrepo.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/oxidized/hook/githubrepo.rb b/lib/oxidized/hook/githubrepo.rb new file mode 100644 index 0000000..85adaab --- /dev/null +++ b/lib/oxidized/hook/githubrepo.rb @@ -0,0 +1,14 @@ +class GithubRepo < Oxidized::Hook + def validate_cfg! + cfg.has_key?('remote_repo') or raise KeyError, 'remote_repo is required' + end + + def run_hook(ctx) + credentials = Rugged::Credentials::SshKeyFromAgent.new(username: 'git') + repo = Rugged::Repository.new(Oxidized.config.output.git.repo) + log "Pushing local repository(#{repo.path})..." + remote = repo.remotes['origin'] || repo.remotes.create('origin', cfg.remote_repo) + log "to remote: #{remote.url}" + remote.push(['refs/heads/master'], credentials: credentials) + end +end |