Skip to content

Commit

Permalink
Support DTO for compass bot.
Browse files Browse the repository at this point in the history
Signed-off-by: EdmondFrank <[email protected]>
  • Loading branch information
EdmondFrank committed Jun 1, 2023
1 parent b5fb30b commit 784e294
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,6 @@ export NOTIFICATION_EXPLORE_URL=/explore
export NOTIFICATION_WECHAT_ACCOUNT_BIND_TEMPLATE_ID=OPENTM415757701
export NOTIFICATION_WECHAT_REPORT_GENERATE_TEMPLATE_ID=OPENTM407521893
export NOTIFICATION_WECHAT_REPORT_SUBSCRIPTION_UPDATE_TEMPLATE_ID=OPENTM412612104

# CI Bots
export BOT_EMAIL=[email protected]
1 change: 1 addition & 0 deletions app/controllers/concerns/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module Common
CELERY_SERVER = ENV.fetch('CELERY_SERVER') { 'http://localhost:8000' }
SUPPORT_DOMAINS = ['gitee.com', 'github.com', 'raw.githubusercontent.com']
SUPPORT_DOMAIN_NAMES = ['gitee', 'github']
BOT_EMAIL = ENV.fetch('BOT_EMAIL') { '[email protected]' }
GITEE_REPO = ENV.fetch('GITEE_WORKFLOW_REPO')
GITHUB_REPO = ENV.fetch('GITHUB_WORKFLOW_REPO')
META_REPO = ENV.fetch('WORKFLOW_REPO_NAME') { 'compass-projects-information' }
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/concerns/gitee_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ def gitee_create_branch(branch_name, refs: 'main')
end

def gitee_post_file(path, message, content_base64, branch_name)
signed_off_message = message + "\n\nSigned-off-by: " + BOT_EMAIL
resp =
Faraday.post(
"#{GITEE_API_ENDPOINT}/repos/#{gitee_owner}/#{gitee_repo}/contents/#{path}",
{ message: message, content: content_base64, branch: branch_name, access_token: GITEE_TOKEN }.to_json,
{ message: signed_off_message, content: content_base64, branch: branch_name, access_token: GITEE_TOKEN }.to_json,
{ 'Content-Type' => 'application/json'}
)
case JSON.parse(resp.body).symbolize_keys
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/concerns/github_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ def github_create_ref(branch_name, sha)
end

def github_put_file(path, message, content_base64, branch_name)
signed_off_message = message + "\n\nSigned-off-by: " + BOT_EMAIL
resp =
RestClient::Request.new(
method: :put,
url: "#{GITHUB_API_ENDPOINT}/repos/#{github_owner}/#{github_repo}/contents/#{path}",
payload: { message: message, content: content_base64, branch: branch_name }.to_json,
payload: { message: signed_off_message, content: content_base64, branch: branch_name }.to_json,
headers: { 'Content-Type' => 'application/json' , 'Authorization' => "Bearer #{GITHUB_TOKEN}" },
proxy: PROXY
).execute
Expand Down
2 changes: 1 addition & 1 deletion app/services/export_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def execute
return
end

output, status = Open3.capture2("git commit -m 'Update at #{DateTime.now.to_s}'", :chdir=>chdir)
output, status = Open3.capture2("git commit -s -m 'Update at #{DateTime.now.to_s}'", :chdir=>chdir)
if !status.success?
job_logger.error "failed to git commit, error: #{output}"
return
Expand Down

0 comments on commit 784e294

Please sign in to comment.