Skip to content

Conversation

lukeleleh
Copy link
Contributor

@lukeleleh lukeleleh commented Sep 22, 2024

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I see several green ci/circleci builds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.
  • I've added or updated relevant unit tests.

Motivation and Context

This update is needed to make the Slack action in Fastlane more flexible by adding support for using emojis as icons in Slack messages. Right now, you can only use image URLs for the icon, even though Slack’s API lets you use emojis too. This change allows users to customize their notifications a bit more by adding emoji icons, which can make messages more fun or visually informative 🤖 🏄

Description

I added a new parameter to the Slack action in Fastlane, allowing users to specify an emoji as the message icon. The new parameter integrates with Slack’s existing API capabilities for setting an emoji as the avatar/icon of a message, offering more customization.

In addition to the new feature, I ensured that the previous functionality, which supports image URLs for the icon, remains unaffected (no breaking changes).

The changes have been tested locally by running the Fastlane Slack action with both emoji and image-based icons. I’ve validated that the correct message format is sent to Slack in each case (see the next section).

Testing Steps

I tested this branch locally using the Slack action with these scenarios:

  1. Message with no icon URL – should display the default Slack icon.
  2. Message with an icon URL – should display the specified image icon.
  3. Message with an icon emoji – should display the specified emoji as the icon.
  4. Message with both an icon URL and emoji – should display the image icon (the icon URL takes priority over the emoji).

I’ve attached the testing lane I used and a screenshot below to show the results for each scenario:

Code
lane :send_slack_messges do
slack(
  message: "Message with no icon URL, should show the default icon",
  username: "User 1",
  default_payloads: []
)

slack(
  message: "Message with icon URL, should show the given icon",
  username: "User 2",
  icon_url: "https://picsum.photos/seed/picsum/48",
  default_payloads: []
)

slack(
  message: "Message with icon emoji, should show the given icon",
  username: "User 3",
  icon_emoji: ":white_check_mark:",
  default_payloads: []
)

slack(
  message: "Message with icon URL and emoji, should show the URL emoji (icon URL is overriden)",
  username: "User 4",
  icon_url: "https://picsum.photos/seed/picsum/48",
  icon_emoji: ":white_check_mark:",
  default_payloads: []
)
end

Result of the previous code:

image

Copy link
Contributor

@lucgrabowski lucgrabowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution 💪 and adding a screenshot with testing result :)

@lucgrabowski lucgrabowski merged commit 43b2a5a into fastlane:master Sep 25, 2024
3 checks passed
@lukeleleh lukeleleh deleted the add-icon-emoji-parameter-to-slack-action branch September 26, 2024 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants