Skip to content

Recipe for including github compare URL in updated message

Kyle Lawlor-Bagcal edited this page Jan 10, 2024 · 2 revisions

If your repo is hosted on github, and you'd like the updated slack message to include a link to the github "compare" diff showing what's changed in the new release, just put this in your custom messaging class:

    def payload_for_updated
      current = fetch(:current_revision)
      previous = fetch(:previous_revision)

      super.tap do |payload|
        if current && previous
          payload[:attachments] ||= []
          payload[:attachments] << {
              title: "Github Diff",
              title_link: "https://github.com/YOUR_ORG/YOUR_PROJ/compare/#{CGI.escape previous}...#{CGI.escape current}",
              short: false
            }
        end
      end
    end

Thanks to @jrochkind

Clone this wiki locally