Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

translate deploy comment, allow to be made by manually set github user

Markus Kahl80007dd48b5a
diff --git a/modules/github_integration/app/workers/cron/check_deploy_status_job.rb b/modules/github_integration/app/workers/cron/check_deploy_status_job.rb
index d40f52c5f5f..7f63cdd1f9e 100644
--- a/modules/github_integration/app/workers/cron/check_deploy_status_job.rb
+++ b/modules/github_integration/app/workers/cron/check_deploy_status_job.rb
@@ -78,6 +78,8 @@ module Cron
# PRs are ever checked for their deployment status.
def update_deploy_status(pull_request, deploy_target)
host = deploy_target.host
+ pr_link = "[#{pull_request.repository}##{pull_request.number}](#{pull_request.github_html_url})"
+ deploy_target_link = "[#{host}](https://#{host})"
ActiveRecord::Base.transaction do
delete_status_check pull_request, deploy_target
@@ -86,7 +88,7 @@ module Cron
comment_on_referenced_work_packages(
pull_request.work_packages,
comment_user,
- "[#{pull_request.repository}##{pull_request.number}](#{pull_request.github_html_url}) deployed to [#{host}](https://#{host})"
+ I18n.t("text_pull_request_deployed_to", pr_link:, deploy_target_link:)
)
end
end
@@ -102,10 +104,16 @@ module Cron
end
##
- # Ideally this would be the github user, but we don't really have a way
- # to identify it outside of the webhook request cycle.
+ # We don't have a proper way to identify it outside of the webhook request cycle.
+ # So, we added this optional setting (which is lacking a UI) as a workaround for now.
def comment_user
- User.system
+ user_id = plugin_settings[:github_user_id].presence
+
+ user_id ? User.find(user_id) : User.system
+ end
+
+ def plugin_settings
+ Hash(Setting.plugin_openproject_github_integration).with_indifferent_access
end
def deploy_status_check(deploy_target, pull_request)
diff --git a/modules/github_integration/config/locales/en.yml b/modules/github_integration/config/locales/en.yml
index 182110277b5..13aafa165bb 100644
--- a/modules/github_integration/config/locales/en.yml
+++ b/modules/github_integration/config/locales/en.yml
@@ -46,3 +46,4 @@ en:
text_deploy_target_api_key_info: >
An OpenProject [API key](docs_url)
belonging to a user who has the global introspection permission.
+ text_pull_request_deployed_to: "%{pr_link} deployed to %{deploy_target_link}"
diff --git a/modules/github_integration/lib/open_project/github_integration/engine.rb b/modules/github_integration/lib/open_project/github_integration/engine.rb
index dade0ae8dc2..5e176ba798f 100644
--- a/modules/github_integration/lib/open_project/github_integration/engine.rb
+++ b/modules/github_integration/lib/open_project/github_integration/engine.rb
@@ -35,6 +35,14 @@ module OpenProject::GithubIntegration
include OpenProject::Plugins::ActsAsOpEngine
+ def self.settings
+ {
+ default: {
+ "github_user_id" => nil
+ }
+ }
+ end
+
initializer "github.feature_decisions" do
OpenProject::FeatureDecisions.add :deploy_targets
end
@@ -42,7 +50,8 @@ module OpenProject::GithubIntegration
register(
"openproject-github_integration",
author_url: "https://www.openproject.org/",
- bundled: true
+ bundled: true,
+ settings:
) do
::Redmine::MenuManager.map(:admin_menu) do |menu|
menu.push :admin_github_integration,