capistrano-dockerbuild 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c76b5158e48a01111cf0484a73d6a29bb0a5fbf739e6436fc07953597368f4a
4
- data.tar.gz: 8d3f8902a8b6c0d236d2b3b2ecf6739ed47eaed40e82419f229bc0dd3215aaac
3
+ metadata.gz: 7580dbb05690bf6529b2fa5c84cf8c31c8d38b3335858af7aa3afdfcda8a8d7d
4
+ data.tar.gz: 691b01a48a7ff2aca50ca20ddcfd93275bc5b77ce27f43e7843564fbeac61d83
5
5
  SHA512:
6
- metadata.gz: b1bc3546464847bfcacff5899ea1a06764eccec638a28e897958b270fb8d4dce3020743fc3f59f5085bc765501b1d5a4514f28b668429a1eee3490720ce819df
7
- data.tar.gz: 545b691af1175f8775765cd478e5f0100aa472e5b4235a57de9c5c7018365fbb584b0d2b347f2ec6a7cfc432e4b0394afb4d33ebfae4e295760253e55c86375c
6
+ metadata.gz: e5a7110eb23e53fd10aa05df4520690637e41a08847b788dd510f7b6ec5b8f48a2ff8919431873ce3e0f15b68ad5e07d0296aff8d4f13503bfacb38946eb0751
7
+ data.tar.gz: a94036ec200c90d80fe321cbb1519e52c933a09d2db08a292d4375b96fd32a072e4c622af238faa85b2d39aa0a6c85255c5be52ea65f69a1abc38fbcb46183f6
data/README.md CHANGED
@@ -50,7 +50,24 @@ Use common variables
50
50
  | docker_remote_tag | no | `-> { fetch(:docker_tag) }` | Use by `docker push docker_registry/docker_remote_repository_name:{{docker_remote_tag}}` |
51
51
  | docker_remote_tag_full | no | `-> { "#{fetch(:docker_registry) &.+ "/"}#{fetch(:docker_remote_repository_name)}:#{fetch(:docker_remote_tag)}" }` | Use by `docker push {{docker_remote_tag_full}}` |
52
52
  | keep_docker_image_count | no | 10 | |
53
+ | git_http_username | no | nil | See below |
54
+ | git_http_password | no | nil | See below |
53
55
 
56
+ If you want to use GitHub Apps installation access token or something to authorize repository access using HTTPS protocol. You can set variables in your config/deploy.rb:
57
+
58
+ ```ruby
59
+ set :git_http_username, -> { ENV["GIT_HTTP_USERNAME"] }
60
+ set :git_http_password, -> { ENV["GIT_HTTP_PASSWORD"] }
61
+ set :repo_url, -> do
62
+ if fetch(:git_http_username) && fetch(:git_http_password)
63
+ "https://github.com/owner/repo.git"
64
+ else
65
+ "git@github.com:owner/repo.git"
66
+ end
67
+ end
68
+ ```
69
+
70
+ Update remote URL always if you set proper value to all of `repo_url`, `git_http_username`, and `git_http_password`.
54
71
 
55
72
  ## Tasks
56
73
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "capistrano-dockerbuild"
7
- spec.version = "0.2.0"
7
+ spec.version = "0.2.1"
8
8
  spec.authors = ["joker1007"]
9
9
  spec.email = ["kakyoin.hierophant@gmail.com"]
10
10
 
@@ -1,3 +1,6 @@
1
+ require "cgi"
2
+ require "uri"
3
+
1
4
  class Capistrano::Dockerbuild < Capistrano::Plugin
2
5
  def set_defaults
3
6
  set_if_empty :docker_build_cmd, -> { [:docker, "build", "-t", fetch(:docker_tag_full), "."] }
@@ -21,4 +24,19 @@ class Capistrano::Dockerbuild < Capistrano::Plugin
21
24
  raise "Need to set :docker_build_base_dir" unless fetch(:docker_build_base_dir)
22
25
  Pathname(fetch(:docker_build_base_dir))
23
26
  end
27
+
28
+ def git_repo_url
29
+ if fetch(:git_http_username) && fetch(:git_http_password)
30
+ URI.parse(repo_url).tap do |repo_uri|
31
+ repo_uri.user = fetch(:git_http_username)
32
+ repo_uri.password = CGI.escape(fetch(:git_http_password))
33
+ end.to_s
34
+ elsif fetch(:git_http_username)
35
+ URI.parse(repo_url).tap do |repo_uri|
36
+ repo_uri.user = fetch(:git_http_username)
37
+ end.to_s
38
+ else
39
+ repo_url
40
+ end
41
+ end
24
42
  end
@@ -5,7 +5,7 @@ namespace :docker do
5
5
  task :check do
6
6
  on fetch(:docker_build_server_host) do
7
7
  execute :mkdir, "-p", dockerbuild_plugin.docker_build_base_path.dirname.to_s
8
- execute :git, :'ls-remote', repo_url, "HEAD"
8
+ execute :git, :'ls-remote', dockerbuild_plugin.git_repo_url, "HEAD"
9
9
  end
10
10
  end
11
11
 
@@ -17,7 +17,7 @@ namespace :docker do
17
17
  info "The repository is at #{dockerbuild_plugin.docker_build_base_path}"
18
18
  else
19
19
  within dockerbuild_plugin.docker_build_base_path.dirname do
20
- execute :git, :clone, repo_url, dockerbuild_plugin.docker_build_base_path.to_s
20
+ execute :git, :clone, dockerbuild_plugin.git_repo_url, dockerbuild_plugin.docker_build_base_path.to_s
21
21
  end
22
22
  end
23
23
  else
@@ -25,7 +25,7 @@ namespace :docker do
25
25
  info t(:mirror_exists, at: dockerbuild_plugin.docker_build_base_path.to_s)
26
26
  else
27
27
  within dockerbuild_plugin.docker_build_base_path.dirname do
28
- execute :git, :clone, "--mirror", repo_url, dockerbuild_plugin.docker_build_base_path.to_s
28
+ execute :git, :clone, "--mirror", dockerbuild_plugin.git_repo_url, dockerbuild_plugin.docker_build_base_path.to_s
29
29
  end
30
30
  end
31
31
  end
@@ -36,6 +36,7 @@ namespace :docker do
36
36
  task update_mirror: :'docker:clone' do
37
37
  on fetch(:docker_build_server_host) do
38
38
  within dockerbuild_plugin.docker_build_base_path do
39
+ execute :git, :remote, "set-url", :origin, dockerbuild_plugin.git_repo_url
39
40
  execute :git, :remote, :update, "--prune"
40
41
  end
41
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-dockerbuild
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - joker1007
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-15 00:00:00.000000000 Z
11
+ date: 2024-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  requirements: []
91
- rubygems_version: 3.3.7
91
+ rubygems_version: 3.5.9
92
92
  signing_key:
93
93
  specification_version: 4
94
94
  summary: Capistrano task definition for `docker build`