Configure Gitea commit signing with SSH key

This commit is contained in:
2026-02-13 16:08:11 +04:00
parent 6e83384da5
commit 161b78be97
2 changed files with 38 additions and 0 deletions

View File

@@ -19,6 +19,17 @@ jwt_secret = gitea_data_bag_item["jwt_secret"]
internal_token = gitea_data_bag_item["internal_token"]
secret_key = gitea_data_bag_item["secret_key"]
apt_repository "git-core-ppa" do
uri "http://ppa.launchpad.net/git-core/ppa/ubuntu"
components ["main"]
key "E1DF1F24"
action :add
only_if do
node['platform'] == 'ubuntu' &&
Gem::Version.new(node['platform_version']) < Gem::Version.new('22.04')
end
end
package "git"
user "git" do
@@ -26,6 +37,13 @@ user "git" do
home "/home/git"
end
directory "/home/git/.ssh" do
owner "git"
group "git"
mode "0700"
recursive true
end
directory working_directory do
owner "git"
group "git"
@@ -100,6 +118,16 @@ config_variables = {
s3_bucket: gitea_data_bag_item["s3_bucket"]
}
bash "Generate git ed25519 keypair" do
user "git"
group "git"
cwd git_home_directory
code <<-EOH
ssh-keygen -t ed25519 -f #{git_home_directory}/.ssh/id_ed25519
EOH
creates "#{git_home_directory}/.ssh/id_ed25519"
end
template "#{config_directory}/app.ini" do
source "app.ini.erb"
owner "git"

View File

@@ -30,6 +30,16 @@ MAX_OPEN_CONNS = 20
ROOT = <%= @repository_root_directory %>
DISABLE_DOWNLOAD_SOURCE_ARCHIVES = true
[repository.signing]
SIGNING_KEY = <%= @git_home_directory %>/.ssh/id_ed25519.pub
SIGNING_NAME = Gitea
SIGNING_EMAIL = git@<%= @domain %>
SIGNING_FORMAT = ssh
INITIAL_COMMIT = always
CRUD_ACTIONS = always
WIKI = always
MERGES = always
# [indexer]
# ISSUE_INDEXER_PATH = /data/gitea/indexers/issues.bleve