|
50 | 50 | block do |
51 | 51 | uri = "#{node['git']['api']['endpoint']}/admin/users/#{node['git']['org']['tasks']}/repos" |
52 | 52 | r = Utils.request(uri, method: Net::HTTP::Post, headers: Constants::HEADER_JSON, |
53 | | - user: Env.get(self, 'login'), pass: Env.get(self, 'password'), |
54 | | - body: { name: name_repo, private: false, auto_init: false, default_branch: 'main' }.json) |
| 53 | + user: Env.get(self, 'login'), pass: Env.get(self, 'password'), |
| 54 | + body: { name: name_repo, private: false, auto_init: false, default_branch: 'main' }.json) |
55 | 55 | Logs.request!(uri, r, [201], msg: "Create #{name_repo}") |
56 | 56 | r.json |
57 | 57 | end |
|
69 | 69 | owner node['app']['user'] |
70 | 70 | group node['app']['group'] |
71 | 71 | mode '0644' |
72 | | - variables(repo: name_repo, |
73 | | - config: node['app']['config'], |
74 | | - org: node['git']['org']['tasks'], |
75 | | - ssh: node['git']['host']['ssh']) |
| 72 | + variables(repo: name_repo, config: node['app']['config'], org: node['git']['org']['tasks'], ssh: node['git']['host']['ssh']) |
76 | 73 | only_if { ::File.directory?("#{path_destination}/.git") } |
77 | 74 | end |
78 | 75 |
|
|
101 | 98 | m = File.join(path_destination, 'main.rb') |
102 | 99 | g = Dir.glob(File.join(path_destination, '*.rb')).sort |
103 | 100 | s = if File.file?(d); 'default.rb' |
104 | | - elsif File.file?(m); 'main.rb' |
105 | | - elsif g.any?; File.basename(g.first) |
106 | | - end |
107 | | - raise 'no ruby script found' unless s |
| 101 | + elsif File.file?(m); 'main.rb' |
| 102 | + elsif g.any?; File.basename(g.first) |
| 103 | + end |
108 | 104 | node.run_state["#{name_repo}_script"] = s |
109 | 105 | end |
110 | 106 | end |
|
124 | 120 | owner node['app']['user'] |
125 | 121 | group node['app']['group'] |
126 | 122 | mode '0644' |
127 | | - variables lazy { { |
128 | | - org: node['git']['org']['tasks'], |
129 | | - repo: name_repo, |
130 | | - script: node.run_state["#{name_repo}_script"], |
131 | | - cron: node.run_state["#{name_repo}_cron"] } } |
| 123 | + variables lazy { { org: node['git']['org']['tasks'], repo: name_repo, |
| 124 | + script: node.run_state["#{name_repo}_script"], cron: node.run_state["#{name_repo}_cron"] } } |
132 | 125 | end |
133 | 126 |
|
134 | 127 | execute "task_repo_base_commit_#{name_repo}" do |
|
141 | 134 | user node['app']['user'] |
142 | 135 | end |
143 | 136 |
|
| 137 | + execute "task_repo_touch_workflow_#{name_repo}" do |
| 138 | + command <<-EOH |
| 139 | + WORKFLOW_FILE="#{path_destination}/.gitea/workflows/ruby.yml" |
| 140 | + if [ -f "$WORKFLOW_FILE" ]; then |
| 141 | + touch "$WORKFLOW_FILE" && git add "$WORKFLOW_FILE" |
| 142 | + git commit --allow-empty -m "touch workflow [skip ci]" || true |
| 143 | + git push origin main || true |
| 144 | + fi |
| 145 | + EOH |
| 146 | + cwd path_destination |
| 147 | + user node['app']['user'] |
| 148 | + not_if { ['127.0.0.1', 'localhost', '::1'].include?(Env.get(self, 'host')) } |
| 149 | + end |
| 150 | + |
144 | 151 | directory path_destination do |
145 | 152 | action :delete |
146 | 153 | recursive true |
|
0 commit comments