act10ns / slack Goto Github PK
View Code? Open in Web Editor NEWSlack messages for GitHub Action workflows, jobs and steps
Home Page: https://github.com/marketplace/actions/slack-github-actions-slack-integration
License: MIT License
Slack messages for GitHub Action workflows, jobs and steps
Home Page: https://github.com/marketplace/actions/slack-github-actions-slack-integration
License: MIT License
Describe the bug
The problem is that the action cannot load the configuration file from any directory outside of .github/workflows
. Consequently, when the configuration file is placed within the 'workflows' directory, it triggers an error within GitHub actions due to a deviation from the expected workflow syntax.
No event triggers defined in "on"
To Reproduce
.github/config
directory.Expected behavior
Ideally, users should have the flexibility to position the configuration file outside of the 'workflows' directory without encountering any issues.
Screenshots
In the following screenshots, you can observe the contrast between placing the configuration file in directories other than .github/workflows and adhering to the 'workflows' directory:
By putting the config file in any directory other than the .github/workflows, the action can not read config template!
# Step 14: Post breaking changes to a Slack channel
- name: Post breaking changes to a Slack channel
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
uses: act10ns/slack@v1
with:
status: complete
channel: "#sci-design-system-breaking-changes"
config: .github/config/slack.yml
if: contains(toJson(github.event.commits.*.message), 'BREAKING CHANGE')
The message is constructed based on the template by putting the config file in the .github/workflows directory.
# Step 14: Post breaking changes to a Slack channel
- name: Post breaking changes to a Slack channel
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
uses: act10ns/slack@v1
with:
status: complete
channel: "#sci-design-system-breaking-changes"
config: .github/workflows/slack.yml
if: contains(toJson(github.event.commits.*.message), 'BREAKING CHANGE')
Desktop (please complete the following information):
I appreciate your attention to this matter and kindly request assistance in resolving this issue to enhance the functionality and usability of the package.
Is your feature request related to a problem? Please describe.
Is it possible to retrieve the outcome
steps inside .github/slack.yml
Describe the solution you'd like
- type: section
fields:
- type: mrkdwn
text: "${{ fromJson(steps.get-step-detail.outputs.result).name }}" # how to retrieve it w/o having to looping(?)
- type: mrkdwn
text: 'URL: ${{ steps.build-and-publish.outputs.internal-sharing-app-url }}' # similar
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
I cannot say it is related to the version bump but it just changed, and this stopped working...
2020-11-16T21:39:53.2810382Z ##[error]TypeError: Cannot read property 'timestamp' of undefined
at Object. (/home/runner/work/_actions/act10ns/slack/v1/dist/index.js:9356:50)
at Generator.next ()
at /home/runner/work/_actions/act10ns/slack/v1/dist/index.js:9281:71
at new Promise ()
at module.exports.570.__awaiter (/home/runner/work/_actions/act10ns/slack/v1/dist/index.js:9277:12)
at Object.send [as default] (/home/runner/work/_actions/act10ns/slack/v1/dist/index.js:9309:12)
at /home/runner/work/_actions/act10ns/slack/v1/dist/index.js:3306:34
at Generator.next ()
at /home/runner/work/_actions/act10ns/slack/v1/dist/index.js:3281:71
at new Promise ()
Is your feature request related to a problem? Please describe.
This is more of a question as It could be lack of YAML knowledge on my end. However, I'm having a hard time getting if: always ()
to work, because I have an if:
statement already being used to identify which environment we're using.
This works just fine, without if: always ()
Example (modified for randomness)
name: SomeTest
on:
repository_dispatch:
types: [SomeTest]
jobs:
build:
runs-on: ubuntu-latest
env:
ENV: ${{ github.event.client_payload.env }}
A_CICD_JOB: ${{ github.event.client_payload.repo_name }}
BRANCH_NAME: ${{ github.event.client_payload.branch_name }}
steps:
- uses: actions/checkout@v2
- name: Set up JDK XX
<BUILD SOME STUFF>
...
...
...
- name: Slack Notify Status UAT
uses: act10ns/slack@v1
if: ${{ env.ENV }} == 'uat'
with:
webhook-url: ${{ secrets.UAT_SOMETEST_SLACK_WEBHOOK_URL }}
status: ${{ job.status }}
channel: '#uat-somechannel'
message: GitHub some test result "${{ job.status }}" on ${{ env.A_CICD_JOB }} - ${{ env.BRANCH_NAME }}
- name: Slack Notify Status Staging
uses: act10ns/slack@v1
if: ${{ env.ENV }} == 'staging'
with:
webhook-url: ${{ secrets.STAGING_SOMETEST_SLACK_WEBHOOK_URL }}
status: ${{ job.status }}
channel: '#staging-somechannel'
message: GitHub some test result "${{ job.status }}" on ${{ env.A_CICD_JOB }} - ${{ env.BRANCH_NAME }}
I've tried various combinations, like so (same for 'staging'):
uses: act10ns/slack@v1
if: |
always() &&
${{ env.ENV }} == 'uat'
with:
I've also tried a simple always() && ${{ env.ENV }} == 'uat'
however, same results as directly above.
Describe the solution you'd like
I think I may just be missing something, if not:
if:
?Describe alternatives you've considered
I can just create two workflow files, however I wanted to check here first as a last option before duplicating that much code.
Additional context
I am using web hooks, not slack apps.
Thank you very much!
Incoming Webhooks are considered legacy now and app webhooks only allow you to post to a single channel, so adding support for app tokens would be awesome!
Describe the bug
The message posted to Slack when my workflow finishes links to a URL of the following form:
https://github.com/<owner>/<repo>/actions?query=<workflow-name>
However, it appears that Github have changed its URLs for actions such that the appropriate URL is now:
https://github.com/<owner>/<repo>/actions/workflows/<workflow-filename>.yml
To Reproduce
Steps to reproduce the behavior:
act10ns/slack@v1
.Expected behavior
I expect to be taken to a page listing recent runs of the appropriate workflow. (I'd prefer to be taken to the run that triggered the message, but that's a separate feature request.)
Screenshots
N/A
Desktop (please complete the following information):
N/A
Smartphone (please complete the following information):
N/A
Additional context
None.
Describe the bug
Build fails when trying to run this action, even though i get slack notifications for the build, it was working fine yesterday but suddenly stopped working. I'm not using a custom slack.yml config, but the action is trying to find one anyways.
To Reproduce
Steps to reproduce the behavior:
Start a deployment build
Expected behavior
The slack notification should be shown and the build should continue to other actions
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Was working fine till yesterday, stopped working without any changes to configuration today.
It would be nice to be able to add a completely custom message to the action that can be sent to the Slack card template. This would enable sending much richer information into Slack such as download links for newly created builds or just additional metadata about the workflow.
One could have a custom message which could be configured as part of the action like so:
- name: slack notification
uses: act10ns/slack@v1
env:
SLACK_WEBHOOK_URL: ${{secrets.SLACK_WEBHOOK_URL}}
with:
status: ${{job.status}}
custom_message: "New beta on channel ${{github.event.inputs.channel}} ready to test at the following link ${{some_output_link}}"
if: success()
Describe the bug
When I used the example above, I got the same template default of actions inside the slack, so I try to set the config example for testing and custom issues, some like slack.yml in the readme page. In the example bellow, Im tested this code.
- name: Report Status
uses: act10ns/[email protected]
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
config: .github/config/slack.yml
if: always()
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_ACTIONS_WEBHOOK }}
ACTIONS_RUNNER_DEBUG: true
ACTIONS_STEP_DEBUG: true
the slack.yml
username: GitHub-CI
icon_url: https://octodex.github.com/images/mona-the-rivetertocat.png
pretext: Triggered via {{eventName}} by {{actor}} {{default action "action"}} {{ref}} `{{diffRef}}`
title: GitHub Actions
title_link: https://support.github.com
text: &text |
*<{{workflowRunUrl}}|Workflow _{{workflow}}_ job _{{jobName}}_ triggered by _{{eventName}}_ is _{{jobStatus}}_>* for <{{refUrl}}|`{{ref}}`>
{{#if description}}<{{diffUrl}}|`{{diffRef}}`> - {{{description}}}{{/if}}
{{#if payload.commits}}
*Commits*
{{#each payload.commits}}
<{{this.url}}|`{{truncate this.id 8}}`> - {{this.message}}
{{/each}}
{{/if}}
fallback: |-
[GitHub] {{workflow}} #{{runNumber}} {{jobName}} is {{jobStatus}}
fields:
- title: Job Steps
value: |-
{{#each jobSteps}}{{#ifneq this.outcome 'skipped'}}{{icon this.outcome}} {{@key}}
{{/ifneq}}{{/each}}
short: false
blocks:
# author
- type: context
elements:
- type: image
image_url: '{{{sender.avatar_url}}}'
alt_text: '{{sender.login}}'
- type: mrkdwn
text: "*<{{sender.html_url}}|{{sender.login}}>*"
# title
- type: section
text:
type: mrkdwn
text: |
*<{{title_link}}|{{title}}>*
# text
- type: section
text:
type: mrkdwn
text: *text
# fields
- type: section
fields:
- type: mrkdwn
text: |-
*Job Steps*
{{#each jobSteps}}{{#ifneq this.outcome 'skipped'}}{{icon this.outcome}} {{@key}}
{{/ifneq}}{{/each}}
- type: section
fields:
- type: mrkdwn
text: "*Workflow*\n<{{{workflowUrl}}}|{{workflow}}>"
- type: mrkdwn
text: "*Git Ref*\n{{ref}} ({{refType}})"
- type: mrkdwn
text: |-
*Run ID*
<{{workflowRunUrl}}|{{runId}}>
- type: mrkdwn
text: "*Run Number*\n{{runNumber}}"
- type: mrkdwn
text: "*Actor*\n{{actor}}"
- type: mrkdwn
text: "*Job Status*\n{{jobStatus}}"
# footer
- type: context
elements:
- type: image
image_url: '{{footer_icon}}'
alt_text: satterly
- type: mrkdwn
text: '{{{footer}}} | <!date^{{ts}}^{date_short_pretty} at {time}|{{ts}}>'
footer: >-
<{{repositoryUrl}}|{{repositoryName}}> {{workflow}} #{{runNumber}}
colors:
success: '#5DADE2'
failure: '#884EA0'
cancelled: '#A569BD'
default: '#7D3C98'
icons:
success: ':white_check_mark:'
failure: ':grimacing:'
cancelled: ':x:'
skipped: ':heavy_minus_sign:'
default: ':interrobang:'
Screenshots
If applicable, add screenshots to help explain your problem.
We have a repo that has some long running system tests. We run these on a schedule and they are run on a self-hosted runner.
Failure messages look like this:
I'm not familiar with what gets supplied in the context and if it's any different for a self-hosted runner. I can see where the message is formatted in the code, so creating a P/R shouldn't be difficult once I can get my head around those details.
I'll be able to circle back to this in a couple weeks, but I might have time to run an experiment or two if you have time to look at it before then.
It may be a nice enhancement to add the commit messages into the slack notification.
I'm trying to send a message using only blocks, but the action don't accept this. Have an default to fields, text, title, footer and authors.
The message structure don't allow the blocks inside the message, always the blocks push at the end of the message.
Lines 229 to 269 in c97e3fd
Lines 334 to 359 in c97e3fd
The feature i propose is omit the default values and only build the message with blocks.
Describe the bug
Can't not use env in slack.yml
To Reproduce
Expected behavior
Can read this env from slack.yml
Additional context
I'm tested use default slack.yml it works, read from env happened this error.
Date and time doesn't look right.
Is your feature request related to a problem?
at this moment the messaging is covering single job steps and talking about its status. I am wondering if it would be possible (and if it is even possible now so pls add an example) over on a higher level and repost on the success of particular jobs in the workflow.
Describe the solution you'd like
We have some Release workflow which consists of several jobs which can be depending internally...
It would be great to have a single slack message that would summarise the workflow status when it ends
Describe alternatives you've considered
Additional context
Is your feature request related to a problem? Please describe.
The package currently emites deprecation message during CI
Describe the solution you'd like
Update to use node 20
Describe alternatives you've considered
None.
At the moment the matrix runs are triggering a notification for each run and the steps: ${{ toJson(steps) }}
ends up having many steps marked ๐ซ and only the specific matrix run with โ๏ธ
Any idea how to filter and only report the current path in the slack notification.
name: Build packages
on:
workflow_dispatch:
push:
tags:
- '*'
jobs:
build-packages:
runs-on: ubuntu-latest
strategy:
matrix:
image-name:
- cake-api
- frontend
- chatapp
- landing
- nginx-proxy
env:
IMAGE_NAME: ${{ matrix.image-name }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
steps:
- uses: actions/checkout@v2
- name: Build frontend
id: build-frontend
if: ${{ matrix.image-name == 'frontend' }}
run: docker build ./web/frontend/ --file ./web/frontend/Dockerfile
- name: Build chatapp
id: build-chatapp
if: ${{ matrix.image-name == 'chatapp' }}
run: docker build ./web/chatapp/ --file ./web/chatapp/Dockerfile
# ...
- name: Push image to GitHub Container Registry
id: push-images-container-registry
run:
- uses: act10ns/slack@v1
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
if: always()
Is your feature request related to a problem? Please describe.
No, not a problem :)
Describe the solution you'd like
Something like this will be helpful
- uses: act10ns/slack0
with:
channels: '#channel1 #channel2'
Describe alternatives you've considered
Use another step with a different channel
Hello,
One of our jobs has this as the last step:
- uses: act10ns/slack@v1
with:
status: ${{ job.status }}
channel: '#build-notifications'
if: always()
In one build, this step failed with a following error:
Error: A request error occurred: read ECONNRESET
Error: Error: A request error occurred: read ECONNRESET
at Object.requestErrorWithOriginal (/home/runner/work/_actions/act10ns/slack/v1/dist/index.js:2694:33)
at IncomingWebhook.send (/home/runner/work/_actions/act10ns/slack/v1/dist/index.js:2584:32)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
As a result:
I do understand that this particular error is caused by the Slack API, but the outcome is so confusing that I decided to create this issue anyway. Looking at your code, there is no error handling around IncomingWebhook.send
call. I don't know if that would help, but maybe you know a way to prevent this from happening.
The best thing which comes to my mind is some basic retry strategy, which is only triggered whenever network errors like this one occur (ignoring the normal Slack errors). Something like promise-retry may be helpful.
Is your feature request related to a problem? Please describe.
I am finding it extremely difficult to successfully setup the advanced slack notifications using the config.yaml file
Describe the solution you'd like
I think a detailed tutorial video about how to use and setup the config.yaml file would be really helpful
I think this tutorial snippets would really help to reduce confusion.
I really want to appreciate you for your efforts and innovation in making this project work.
Hello, I just found your great GitHub Action yesterday and integrated it into our builds. It's exactly what I was looking for.
Coming from Azure Pipelines, the only thing I'm really missing is an indication of the Duration. Here's a stock screenshot of some of their output:
I'd like to suggest a formatting change for improved readability... I tried to recreate what it would look like with formatting below:
(usericon) linkedusername
Workflow run Integration Build succeeded
Branch
develop
Trigger
Push
Job
main-job
Duration
00:34:32
Where the Branch/Trigger/Job/Duration are done using the grid kind of format where they default to showing in two columns.
I'm trying to add a button to my message utilizing the actions
block, like so:
blocks:
- type: actions
elements:
- type: button
text:
type: plain_text
emoji: true
text: ":github: View"
However, when I add this, my action fails with a An HTTP protocol error occurred: statusCode = 400
error. I assume something about the formatting here is what's causing the action to fail (and the message to not be sent), but since your docs do not specify the formatting for blocks, I'm left to guess based on your slack.yml
file in this repository (which doesn't demonstrate actions
blocks).
Is your feature request related to a problem? Please describe.
I was trying to break down long github workflow using reusable workflow. However, act10ns/slack does only support env.SLACK_WEBHOOK_URL
as environment variable while reusable workflow is missing that context and has only inputs
& secrets
.
Describe the solution you'd like
If possible to have an alternative way to set SLACK_WEBHOOK_URL
using secrets
which kind of common or through direct parameter with:
Describe alternatives you've considered
Currently, no workaround it. I just keep single file for whole process.
Additional context
No
I've added your lovely plugin to our build as advised in the readme, but we're seeing something a bit disappointing in the "steps" output in Slack:
Any idea what we're doing wrong?
Just added this to my workflow and running it locally with act
and I got this error:
TypeError: Cannot read property 'replace' of undefined%0A at Object.<anonymous> (/run/act/actions/[email protected]/dist/index.js:6832:35)%0A at Generator.next (<anonymous>)%0A at /run/act/actions/[email protected]/dist/index.js:6760:71%0A at new Promise (<anonymous>)%0A at module.exports.570.__awaiter (/run/act/actions/[email protected]/dist/index.js:6756:12)%0A at Object.send [as default] (/run/act/actions/[email protected]/dist/index.js:6788:12)%0A at /run/act/actions/[email protected]/dist/index.js:1427:38%0A at Generator.next (<anonymous>)%0A at /run/act/actions/[email protected]/dist/index.js:1401:71%0A at new Promise (<anonymous>)
Which seems to point to this: https://github.com/act10ns/slack/blob/master/dist/index.js#L6832
Is your feature request related to a problem? Please describe.
It seems that this action allows to send status only for steps. This might create noise in the chat history
Describe the solution you'd like
I want to have the following yml configuration and send the message to slack once when all jobs have been finished with failure or success
jobs:
format:
steps:
test:
steps:
build:
steps:
notify:
needs: [format, test, build]
steps:
send status message to slack preferably including the artifact links generated during the build step
instead of the status of steps provide the status of jobs
eg
format - ok
test - fail
build - fail
Describe alternatives you've considered
https://github.com/technote-space/workflow-conclusion-action
It does what I'm asking for but no longer maintained
**Is your feature request related to a problem? **
Here my workflow :
build:
runs-on: ubuntu-latest
steps:
- name: ๐ Checkout ๐
uses: actions/[email protected]
id: checkout
- name: ๐ง Setup JDK 11 ๐ง
id: setup_jdk11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'ion for gradlew
- name: ๐ง Build ๐ง
id: gradle_build
run: ./gradlew build jacocoTestReport sonar --info
- name: ๐ฃ Report to slack ๐ฃ
uses: act10ns/slack@v2
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
if: always()
As you can see it's displaying the task id which have some limitations because it's an id
Describe the solution you'd like
Displaying the name of the task will be nicer and allow me more customization (emoji ...)
Describe the bug
We want to tag users and user groups in every git-hub action failure alert , but couldn't able to do it , even tried with custom flags , not working ,
Please help on this .
To Reproduce
Steps to reproduce the behavior:
name: Test
on:
push:
branches:
- test-branch
jobs:
Test:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.18
uses: actions/setup-go@v2
with:
go-version: 1.181
- name: Notify slack in case of failure
if: failure()
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
uses: act10ns/slack@v1
with:
channel: '#test-slack'
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
color: danger
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
use the YML file with both blocks and fields as slack message template. Integrate this with github actions. Only, receiving the message with fields.
To Reproduce
use https://github.com/act10ns/slack/blob/master/__tests__/fixtures/slack-blocks.yml as a slack message template while integrate with the github.
Expected behavior
need to receive two massages, one with fields and second with blocks
FYI:
This is working as expected with unit test cases
Is your feature request related to a problem? Please describe.
Github action workflows have started outputting messaging around actions that are still Node 12 which fell out of support in April 2022.
In this blog post github outlines their plan to deprecate and remove Node 12 support
https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/
Describe the solution you'd like
I'd like to see the slack action upgraded to node 16 so these warnings go away
Describe the bug
We have this https://github.com/ice-blockchain/mobile-app repo.
99% of the time the action fails cuz something about commit message isnt right.
To Reproduce
Steps to reproduce the behavior:
Check the history or the CICD action and see the failure in this step.
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.