Merge pull request 'Upgrade Gitea to 1.19, configure Gitea Actions, set up Actions runners' (#482) from chore/upgrade_gitea into master
Reviewed-on: #482
This commit was merged in pull request #482.
This commit is contained in:
@@ -1,14 +1,20 @@
|
||||
gitea_version = "1.18.0"
|
||||
gitea_version = "1.19.0"
|
||||
node.default["gitea"]["version"] = gitea_version
|
||||
node.default["gitea"]["binary_url"] = "https://dl.gitea.io/gitea/#{gitea_version}/gitea-#{gitea_version}-linux-amd64"
|
||||
node.default["gitea"]["binary_checksum"] = "b45b715d519a97086208c6b42528d291dd1c4dfdf40321dc940030e1cf3de6e6"
|
||||
node.default["gitea"]["binary_checksum"] = "51e8d46a2634e5b5f4266eee8ca4689b5932caf692f23d06cbe5d2eaffe56079"
|
||||
node.default["gitea"]["working_directory"] = "/var/lib/gitea"
|
||||
node.default["gitea"]["port"] = 3000
|
||||
node.default["gitea"]["postgresql_host"] = "localhost:5432"
|
||||
node.default["gitea"]["nginx"]["domain"] = "gitea.kosmos.org"
|
||||
|
||||
node.default["gitea"]["config"] = {
|
||||
"actions": {
|
||||
"enabled": true
|
||||
},
|
||||
"webhook": {
|
||||
"allowed_host_list" => "external,127.0.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
node.default["gitea"]["act_runner"]["download_url"] = "https://dl.gitea.com/act_runner/main/act_runner-main-linux-amd64"
|
||||
node.default["gitea"]["act_runner"]["checksum"] = "577ec7c64e7458b1e97cbe61d02da1ba1f4ddf24281b175f24f65101e72c000c"
|
||||
|
||||
89
site-cookbooks/kosmos_gitea/recipes/act_runner.rb
Normal file
89
site-cookbooks/kosmos_gitea/recipes/act_runner.rb
Normal file
@@ -0,0 +1,89 @@
|
||||
#
|
||||
# Cookbook:: kosmos_gitea
|
||||
# Recipe:: act_runner
|
||||
#
|
||||
|
||||
working_directory = node["gitea"]["working_directory"]
|
||||
gitea_credentials = data_bag_item("credentials", "gitea")
|
||||
runners = gitea_credentials["runners"]
|
||||
|
||||
begin
|
||||
gitea_host = search(:node, "role:gitea").first["knife_zero"]["host"]
|
||||
rescue
|
||||
Chef::Log.warn('No server with "gitea" role. Stopping here.')
|
||||
return
|
||||
end
|
||||
|
||||
apt_repository 'docker' do
|
||||
uri 'https://download.docker.com/linux/ubuntu'
|
||||
key 'https://download.docker.com/linux/ubuntu/gpg'
|
||||
components ['stable']
|
||||
end
|
||||
|
||||
%w[
|
||||
docker-ce
|
||||
docker-ce-cli
|
||||
containerd.io
|
||||
docker-buildx-plugin
|
||||
].each do |apt_pkg|
|
||||
package apt_pkg
|
||||
end
|
||||
|
||||
remote_file "/usr/local/bin/act_runner" do
|
||||
source node["gitea"]["act_runner"]["download_url"]
|
||||
checksum node["gitea"]["act_runner"]["checksum"]
|
||||
mode "0750"
|
||||
end
|
||||
|
||||
directory "#{working_directory}/runners" do
|
||||
mode "0700"
|
||||
end
|
||||
|
||||
runners.each do |runner|
|
||||
runner_name = "gitea-runner-#{runner["org"]}"
|
||||
runner_dir = "#{working_directory}/runners/#{runner["org"]}"
|
||||
|
||||
directory runner_dir do
|
||||
mode "0700"
|
||||
end
|
||||
|
||||
bash "register_#{runner["org"]}_runner" do
|
||||
cwd runner_dir
|
||||
code <<-EOF
|
||||
act_runner register \
|
||||
--no-interactive \
|
||||
--instance http://#{gitea_host}:#{node["gitea"]["port"]} \
|
||||
--name #{runner_name} \
|
||||
--token #{runner["token"]}
|
||||
EOF
|
||||
not_if { File.exist?("#{runner_dir}/.runner") }
|
||||
end
|
||||
|
||||
systemd_unit "#{runner_name}.service" do
|
||||
content({
|
||||
Unit: {
|
||||
Description: "Gitea Actions Runner for '#{runner["org"]}' org",
|
||||
Documentation: ["https://gitea.com/gitea/act_runner"],
|
||||
Requires: "gitea.service",
|
||||
After: "syslog.target network.target"
|
||||
},
|
||||
Service: {
|
||||
Type: "simple",
|
||||
WorkingDirectory: runner_dir,
|
||||
Environment: "HOME=/root",
|
||||
ExecStart: "/usr/local/bin/act_runner daemon",
|
||||
Restart: "always",
|
||||
},
|
||||
Install: {
|
||||
WantedBy: "multi-user.target"
|
||||
}
|
||||
})
|
||||
verify false
|
||||
triggers_reload true
|
||||
action [:create]
|
||||
end
|
||||
|
||||
service runner_name do
|
||||
action [:enable, :start]
|
||||
end
|
||||
end
|
||||
@@ -107,3 +107,8 @@ MINIO_LOCATION=<%= c["location"] %>
|
||||
MINIO_USE_SSL=<%= c["use_ssl"] %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if @config["actions"]["enabled"] %>
|
||||
[actions]
|
||||
ENABLED = true
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user