rtcamp / action-slack-notify Goto Github PK
View Code? Open in Web Editor NEWGitHub Action for sending a notification to a Slack channel
Home Page: https://github.com/rtCamp/github-actions-library
License: MIT License
GitHub Action for sending a notification to a Slack channel
Home Page: https://github.com/rtCamp/github-actions-library
License: MIT License
I'd like to use this action to notify Slack if one of my steps fails, like so:
- name: Slack Notify dotnet-build Failure
if: failure()
uses: rtCamp/[email protected]
env:
SLACK_TITLE: ":rotating_light: dotnet-build Failure"
SLACK_MESSAGE: "My failure message..."
This would be the last step in one of my jobs, and I have another job that relies on this first job with needs
. What I'm wondering is if failure()
is true, and this action to notify Slack runs and succeeds, is the exit code for this job considered a success (due to the Slack notification), or a failure (due to the step that failed prior to the Slack notification)?
I recently started noticing that the Action URL generated is pointing to a dead link. Looking at the source code it seems to use the GITHUB_SHA
env variable to dynamically generate the link. However, this SHA seems to be incorrect. If I update the link in my browser to use the commit sha of the head of my branch the link correctly works again. For example in a Github Action this is ${{ github.event.pull_request.head.sha }}
. This may not be a issue exactly with this tool but perhaps it would be beneficial to add a override env variable to allow passing in this sha. I've tried doing this already but it doesn't seem like I can override GITHUB_SHA
as is.
I have set MSG_MINIMAL: true
but I still have
Ref
Event
Actions URL
I also tried MSG_MINIMAL: "true"
but result is same
can you help me
Is there a way not to build every time? it's consuming 1 minute for every action I run. This has impact in my billing as I run a lot of actions per month
First of all, thank you so much for your plugin.
It's really good :)
By the way, I want some requests. It might be silly requests.
line break
with message or titleHello\nWorld
Hello\nWorld
Hello%0AWorld
Action URL link
short like belowI'm having trouble getting env variables into the slack message like so:
SLACK_MESSAGE: "Staging deployment complete: $GITHUB_SHA ${GITHUB_SHA}"
None of these seem to work. Am I doing something wrong?
Our builds are failing with the following error:
Run rtCamp/action-slack-notify@v2
/usr/bin/docker run --name ghcriortcampactionslacknotifyv213_709c93 --label 5588e4 --workdir /github/workspace --rm -e NODE_AUTH_TOKEN -e SLACK_WEBHOOK -e SLACK_USERNAME -e SLACK_ICON_EMOJI -e MSG_MINIMAL -e SLACK_MESSAGE -e SLACK_COLOR -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/grill/grill":"/github/workspace" ghcr.io/rtcamp/action-slack-notify:v2.1.3
Unable to find image 'ghcr.io/rtcamp/action-slack-notify:v2.1.3' locally
v2.1.3: Pulling from rtcamp/action-slack-notify
c9b1b535fdd9: Pulling fs layer
f597b81b5d49: Pulling fs layer
5315175e77ba: Pulling fs layer
180cd15dbe12: Pulling fs layer
f47731e8b606: Pulling fs layer
35c5edac0302: Pulling fs layer
25c20a50cc35: Pulling fs layer
180cd15dbe12: Waiting
f47731e8b606: Waiting
35c5edac0302: Waiting
25c20a50cc35: Waiting
docker: error pulling image configuration: denied: unauthenticated: User cannot be authenticated with the token provided
Looks like someone made the image private.
Hi,
Is it possible to release the current master branch?
This allows me to set a stable version for usage in my pipeline.
Hi, would it be possible for this to update the message field when the event is on pull_request? Currently it comes back as null.
It would be also helpful if it came back with success or not if the current job was succesful etc
Thank you
Run rtCamp/action-slack-notify@v2
env:
IMAGE_REPO: ***/***
IMAGE_TAG: sha-c8a3b726c80f7a55cd22e5d4f4bf578dec90acf5
SLACK_COLOR: success
SLACK_WEBHOOK: ***
/usr/bin/docker run --name ghcriortcampactionslacknotifyv213_d2b458 --label c3f261 --workdir /github/workspace --rm -e IMAGE_REPO -e IMAGE_TAG -e SLACK_COLOR -e SLACK_WEBHOOK -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/ubuntu/stacks/system/github-actions-work/4dbfa5e3e9149/_temp/_github_home":"/github/home" -v "/home/ubuntu/stacks/system/github-actions-work/4dbfa5e3e9149/_temp/_github_workflow":"/github/workflow" -v "/home/ubuntu/stacks/system/github-actions-work/4dbfa5e3e9149/_temp/_runner_file_commands":"/github/file_commands" -v "/home/ubuntu/stacks/system/github-actions-work/4dbfa5e3e9149/***/***":"/github/workspace" ghcr.io/rtcamp/action-slack-notify:v2.1.3
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
standard_init_linux.go:219: exec user process caused: exec format error
Hi,
is there any way to add a custom message on slack with the Tests Results executed on the job?
I saved the results on a JSON file and I can easily do a cat on the file to see the results in plain text, but I couldn't find a way to display this message as SLACK_MESSAGE.
Is there an easy way to do it? Thanks!
SLACK_ICON
github action env vars
https://github.com/jmeridth?size=48 is a valid image
results
SLACK_ICON_EMOJI
github action env vars
results (I think this is a result of #89)
Both keep just showing the app icon.
What am I doing wrong?
Thank you for any assistance you can provide. Cheers.
I'm using a .yml workflow file, and trying to use this action. I am having trouble understanding how to pass the slack webhook url in YAML format, since it seems to be passed in separately from the env variables?
Currently the package only supports using an icon with a URL, but it would be nice to be able to use built in Slack Emoji's using the icon_emoji
property as an alternative.
Seeing this error when using this action on a self-hosted runner (uses: rtCamp/[email protected]
)
Pull down action image 'rtcamp/action-slack-notify:v2.0.2'
/usr/bin/docker pull rtcamp/action-slack-notify:v2.0.2
Error response from daemon: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit
Warning: Docker pull failed with exit code 1, back off 5.965 seconds before retry.
/usr/bin/docker pull rtcamp/action-slack-notify:v2.0.2
Error response from daemon: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit
Warning: Docker pull failed with exit code 1, back off 8.716 seconds before retry.
/usr/bin/docker pull rtcamp/action-slack-notify:v2.0.2
Error response from daemon: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit
Is there a different public repository that can be used?
First, thank you for making this action available to us all 💐
Slack enables setting an icon for the incoming message on the webhook con figuration and I want to use the icon I set there, instead of the action's default. Is there an option for that?
Hi,
I wanted to know if its possible to make the actionUri configurable or atleast point to the commit instead of its checks?
Maybe creating an env variable to append the /checks onto the action URI
Kind regards,
Rajiv
Would it be overly complex to add the option to mention someone? sadly bots don't trigger notifications for keywords so the only option would be to manually notify users --- even using the member id would be super helpful.
Hi,
Until the action is not supported on windows-latest, it should be written in the documentation that it runs only on ubuntu.
Thanks
The hostname github.com
appears to be hard-coded into the links for the Actions URL and Commit hash, making the action unsuitable for users on GitHub Enterprise Server where the host is not github.com
. The GITHUB_SERVER_URL
environment variable should be used instead (see https://docs.github.com/en/actions/reference/environment-variables)
version: rtcamp/action-slack-notify:v2.1.2
runs-on: ubuntu-latest
workflow triggered by workflow_dispatch
(manually)
For some reason I get this kind of error:
Error sending message: Post "***": unsupported protocol scheme ""
I've defined step like this:
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: 'test'
SLACK_MESSAGE: ':rocket:'
SLACK_TITLE: 'test'
SLACK_USERNAME: CI-bot
SLACK_WEBHOOK: ${{ secrets.SLACK_BOT_TOKEN }}
secret and channel should be valid. Any idea what could be wrong?
Used the example from documentation:
on: push
name: Slack Notification Demo
jobs:
slackNotification:
name: Slack Notification
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Slack Notification
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
Configured a secret: SLACK_WEBHOOK on
https://github.com/organizations/myproject/settings/secrets
Getting error:
[ERROR] Secret SLACK_WEBHOOK
is missing. Please add it to this action for proper execution.
Not sure what I am missing.
(also your documentation has a broken link for github documentation for setting secrets)
First of all: Thank you for the good work here. Good job. 👍
I'm quite new to Github Actions and would like to ask if there is any way to avoid that in every single job (we use it to send a Slack notification in the case of a faillure) the container for this Action here gets built again?
Thank you in advance.
Event: pull_request
Actions URL: https://github.com/weipengzhu/testaction/commit/7f91b6abdebd55ef0e50ce12235fbfde024b6869/checks
Many companies are using github enterprices, so github.com url won't work for them
No matter what syntax I chose, the Icon Emoji is never being shown. I tried house
, :house:
and ':house:'
without success. Any idea for the reason? Did Slack change anything on their side?
- name: Slack Notification
uses: rtCamp/[email protected]
env:
SLACK_CHANNEL: teg-baugebiets-map
SLACK_ICON_EMOJI: ':house:'
SLACK_MESSAGE: 'New version: https://blabla/index.html'
SLACK_TITLE: 'Hausbau'
SLACK_USERNAME: The Architect
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
Currently the package sends Repo Action URL to Slack like below:
It shows history of workflows, and would be nice to show the corresponding workflow like this.
https://github.com/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}/checks
Example URL:
https://github.com/417-72KI/SSGH/commit/a3c27c06d820ae0d7a1947495c1da006f34867e2/checks
Right now the actor is always who triggered the action, but it would be nice if this could be customized (i.e. manually pick the PR author even if it is triggered from someone else merging it, etc). Related - an option to hide this if it's not relevant
Thanks for the great job on this action. I was checking the releases on this repo and I saw that the last one was make almost a year ago, any plans to create a new one to have the latest changes included?
Currently, when you set a workflow that runs automatically based on a schedule event, the username that appears in the notification is the one from the user that commited this change. This is undesirable and I would like to remove it.
I am trying to send Slack notification when the job is running using macos-latest.
Error received is:
##[error]Container action is only supported on Linux
I am aware that Dockerfile is using alpine
distribution. Is there a way we can achieve the same for macos?
It would be good to allow the use of Vault AppRoles to authenticate against vault, rather than tokens. Here's an example of how this might be done, albeit for Jenkins.
Currently the plugin sets default values for these:
export SLACK_ICON=${SLACK_ICON:-"https://avatars0.githubusercontent.com/u/43742164"}
export SLACK_USERNAME=${SLACK_USERNAME:-"rtBot"}
IMHO it would be better to leave them empty, in which case Slack would use the values defined in the webhook itself:
I'm attempting to notify our dev group when a release is made to also include the release notes. I have the trigger tied to the release and the release notes generate for the linked tag. However the release notes do not show in the SLACK_MESSAGE
. Is there a specific way this needs to be configured that you could provide me an example of?
workflow.yml:
name: Release Notification
on:
release:
types: [published]
jobs:
slackNotification:
name: Release Notification
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Release Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_USERNAME: Release Notification
SLACK_WEBHOOK: ${{ secrets.SLACK_RELEASE_URL }}
Is this action able to notify into Slack when another action run passes, fails, or when another action changes from passing to failing or failing to passing? If so, could you provide an example?
I know the docs advise against doing this, but is there a way to do this at the moment with anything other than a plain text string? I would like to add a URL or interpolate another value such as an environment variable in this field if possible. In the case of passing a URL currently to SLACK_MESSAGE, the value output in slack is null.
Example:
SLACK_MESSAGE: 'this is a test'
Output on Slack: 'this is a test'
SLACK_MESSAGE: 'https://someurl.com'
Output on Slack: null
Thanks!
Why am I receiving can't open '/github/workspace/.github/hosts.yml'?
I'd love to be able to slim down the messages being sent. I don't really need the Ref
, Event
and Action URL
in most cases. Can we add an option to hide these? Or maybe to collapse them somehow to take up less space in a channel?
Hi, when following the docs that say
You can pass ${{job.status}} for automatic coloring or an RGB value like #efefef which would change color on left side vertical line of Slack message.
No color is used.
We use
SLACK_COLOR: ${{ job.status }}
SLACK_MESSAGE: Workflow ${{ job.status }}
And see the message showing "Workflow success", so job.status
is set to "success".
Sorry for such a basic question, but any help would be appreciated. I'm trying to make the slack notification change colors depending on the Github Action's success, cancellation, or failure.
The following seems to work for me:
- name: Slack Notification - Success
if: success()
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
- name: Slack Notification - Failure
if: cancelled() || failure()
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_COLOR: 'danger'
But is there a more efficient way to write this? Seems like a lot of code just to change color. I'm not seeing a way to use if conditionals to change env
values...otherwise I would set SLACK_COLOR
to good
or danger
if success/cancel/failure.
- uses: actions/checkout@v2
- name: Send Slack Notification
uses: rtCamp/[email protected]
env:
SLACK_WEBHOOK: 'https://xxxx'
SLACK_TITLE: ':rocket:【Android】App Tester:rocket:\nバージョン: v${VERSION}(${BUILD_NUMBER})\nリリースノート:\n${RELEASE_NOTE}'
At the moment, to get a beautiful markdown in slack, I need to convert input first with this action https://github.com/LoveToKnow/slackify-markdown-action. My input message looks like [${{github.event.issue.title}}](${{github.event.issue.html_url}}) \n ${{github.event.issue.body}}
so I really cannot manually make it "slack" compatible as I do not have control over issue body.
but it looks like it is a simple as adding https://github.com/jsarafajr/slackify-markdown and enabling someone to specify if they want to slackify markdown in message or not.
MSG_MINIMAL
setting to true env var is not working
Hi, it would be awesome if we could add an attachment env var to support adding a file such as html report.
i've tried using some of the other github actions that have this but they don't seem to work and i've had best success with this one.
I would like to propose to add threading support. In our workflow we create a Slack message and later on we would like to add more replies to it.
In order to do this action needs support ts
input and output variables as described here: https://api.slack.com/messaging/sending#threading
I'm not too much familiar with Go, but I can provide a PR if you are ok with this change and can give some guidance on how I could implement this.
I have the SLACK_WEBHOOK
var configured in Secrets. I am trying to use this
env:
SLACK_MESSAGE: 'Post Content: Testing slackNotifications from github-actions.'
SLACK_CHANNEL: '#test'
SLACK_USERNAME: github-actions-test
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
If I have the webhook url hard-coded it works fine, if i try to pull it from secrets, it throws this error. Any thoughts why?
Secret
SLACK_WEBHOOK is missing. Please add it to this action for proper execution.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.