Skip to content

Commit

Permalink
Add threaded Changelog to release message
Browse files Browse the repository at this point in the history
Co-authored-by: Jim Gay <[email protected]>
  • Loading branch information
xsavvyx and saturnflyer committed Feb 5, 2025
1 parent 7f9ebd5 commit 824b3d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Changed

- Reset the production branch to the staging branch instead of rebasing.
- Deploy slack message now threads the changelog for the release.
11 changes: 10 additions & 1 deletion lib/discharger/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def self.create(name = :release, tasker: Rake::Task, &block)
attr_accessor :commit_identifier
attr_accessor :pull_request_url

attr_reader :last_message_ts

# Reissue settings
attr_accessor(
*Reissue::Task.instance_methods(false).reject { |method|
Expand Down Expand Up @@ -146,6 +148,11 @@ def define
["git push origin v#{current_version}"]
) do
tasker["#{name}:slack"].invoke("Released #{app_name} #{current_version} to production.", release_message_channel, ":chipmunk:")
if last_message_ts.present?
text = File.read(Rails.root.join(changelog_file))
tasker["#{name}:slack"].reenable
tasker["#{name}:slack"].invoke(text, release_message_channel, ":log:", last_message_ts)
end
syscall ["git checkout #{working_branch}"]
end

Expand Down Expand Up @@ -209,17 +216,19 @@ def define
end

desc "Send a message to Slack."
task :slack, [:text, :channel, :emoji] => :environment do |_, args|
task :slack, [:text, :channel, :emoji, :ts] => :environment do |_, args|
args.with_defaults(
channel: release_message_channel,
emoji: nil
)
client = Slack::Web::Client.new
options = args.to_h
options[:icon_emoji] = options.delete(:emoji) if options[:emoji]
options[:thread_ts] = options.delete(:ts) if options[:ts]

sysecho "Sending message to Slack:".bg(:green).black + " #{args[:text]}"
result = client.chat_postMessage(**options)
instance_variable_set(:@last_message_ts, result["ts"])
sysecho %(Message sent: #{result["ts"]})
end

Expand Down

0 comments on commit 824b3d1

Please sign in to comment.