Giter Club home page Giter Club logo

slack-workflow-status's Introduction

Slack Workflow Status

This action will post workflow status notifications into your Slack channel. The notification includes the name of the Actor, Event, Branch, Workflow Name, Status and Run Durations. This action can optionally include the status and duration of individual jobs in a workflow to quickly help you identify where failures and slowdowns occur.

Action Inputs

Name Required Description
slack_webhook_url required Create a Slack Webhook URL using the Incoming Webhooks App. It is recommended that you create a new secret on your repo SLACK_WEBHOOK_URL for holding this value, and passing it to the action with ${{secrets.SLACK_WEBHOOK_URL}}.
repo_token required A token is automatically available in your workflow secrets var. ${{secrets.GITHUB_TOKEN}}. You can optionally send an alternative self-generated token.
include_jobs optional When set to true, include individual job status and durations in the slack notification. When false only the event status and workflow status lines are included. When set to on-failure — individual job status is reported only if workflow failed. Default is true.
jobs_to_fetch optional Sets the number of jobs to fetch (for workflows with big number of jobs). Default is 30.
include_commit_message optional When set to true, include the workflow head commit message title in the slack notification. Default is false.
channel optional Accepts a Slack channel name where you would like the notifications to appear. Overrides the default channel created with your webhook.
name optional Allows you to provide a name for the slack bot user posting the notifications. Overrides the default name created with your webhook.
icon_emoji optional Allows you to provide an emoji as the slack bot user image when posting notifications. Overrides the default image created with your webhook. Emoji Code Cheat Sheet
icon_url optional Allows you to provide a URL for an image to use as the slack bot user image when posting notifications. Overrides the default image created with your webhook.

Usage

To use this action properly, you should create a new job at the end of your workflow that needs all other jobs in the workflow. This ensures that this action is only run once all jobs in your workflow are complete.

This action requires read permission of actions scope. You should assign a job level actions permission if workflow level actions permission is set none.

name: World Greeter
on:
  push:
    branches: [ master, staging ]
jobs:
  job-1:
    runs-on: ubuntu-latest
    steps:
      - name: Say Hello
        run: echo "Hello"
  job-2:
    runs-on: ubuntu-latest
    steps:
      - name: Say World
        run: echo "World"
  slack-workflow-status:
    if: always()
    name: Post Workflow Status To Slack
    needs:
      - job-1
      - job-2
    runs-on: ubuntu-latest
    # actions.read permission is required.
    permissions:
      actions: 'read'
    steps:
      - name: Slack Workflow Notification
        uses: Gamesight/slack-workflow-status@master
        with:
          # Required Input
          repo_token: ${{secrets.GITHUB_TOKEN}}
          slack_webhook_url: ${{secrets.SLACK_WEBHOOK_URL}}
          # Optional Input
          channel: '#anthony-test-channel'
          name: 'Anthony Workflow Bot'
          icon_emoji: ':poop:'
          icon_url: 'https://avatars0.githubusercontent.com/u/1701160?s=96&v=4'

This action can also be used for Pull Request workflows and will include pull request information in the notification.

developed and maintained by: gamesight.io

slack-workflow-status's People

Contributors

anthonykinson avatar d-seion avatar dcelasun avatar dependabot[bot] avatar dovnaralexander avatar houjunchen avatar nmalaguti avatar ojab avatar rsyvarth avatar sampo02 avatar sjohnr avatar swfz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

slack-workflow-status's Issues

PR's link in notification is not working.

スクリーンショット 2021-03-05 9 13 19

If you click this #2307, the following message will be displayed.

{
  "message": "Not Found",
  "documentation_url": "https://docs.github.com/rest/reference/pulls#get-a-pull-request"
}

Thanks.

`v1` branch?

Since there is v1 already — maybe make a branch? I'm not comfortable enough to use master since it can suddenly switch to incompatible v2 and I don't want to stick to versions since I'll probably miss some potential bugfixes.

Not showing the statuses of individual jobs in the Message

Here is the job I wrote for slack notification for github action:

   if: always()
   name: Post Workflow Status To Slack
   needs: squash-merge
   runs-on: ubuntu-latest
   # actions.read permission is required.
   permissions:
     actions: 'read'
   steps:
     - name: Slack Workflow Notification
       uses: Gamesight/[email protected]
       with:
          # Required Input
         repo_token: ${{secrets.GITHUB_TOKEN}}
         slack_webhook_url: ${{secrets.SLACK_WEBHOOK_URL}}
         include_jobs: 'true'
         # Optional Input
         channel: '#dps-cicd-flow'
         name: 'GitHub Action CI Bot'
         icon_emoji: ':squirrel:'
         icon_url: 'https://avatars0.githubusercontent.com/u/1701160?s=96&v=4'

And in the notification message it does not show (tick/cross) for succeeded and failed jobs. I am getting this notification in my slack channel:
image

Ideally, it should show statuses for each individual jobs.
Doc ref: https://github.com/marketplace/actions/slack-workflow-notifications
Ideally, it should show ticks on succeeded jobs and cross on failed jobs like mentioned in their docs:
image

Help is needed on P0, Please do help me achieve this using this workflow ASAP, Thanks

Slack notifications fails when workflow permission is set to read

Hey, so I am failing to send notifications to my slack channel. after invistegating the problem I found out that the task is failing because I've changed my repo settings.

Go to settings >> actions >> general then under Workflow permissions choose Read repository contents permission doing that the slack notification will fail to send notifications.

I've tried to create a costume access token, when I create a token that has full access to the repo the workflow works fine and notifications are sent

 repo : Full control of private repositories

but if I don't give a full access to the repo the job will fail, even if I select all of the sub categories underneath the repo permission

 repo:status : Access commit status
 repo_deployment : Access deployment status
 public_repo : Access public repositories
 repo:invite : Access repository invitations
 security_events : Read and write security events

I am giving it the same access levels as the repo permission but it is still failing. I've checked the source code and as far as I can see you're requesting only read access? but I don't know why the job is failing.

To make it short, I do not want to give a full access token to the workflow. to send slack notification.

Pull request description can include external PRs

Current behavior:

When building the status_string with something like "Failed: xyz's pull_request #X from Y to Z", the description sometimes includes pull requests from external repositories (forks) that reference a particular commit. This is very surprising and makes the notification look like it's coming from someone else's fork.

Here's an example:

Screen Shot 2022-05-02 at 12 35 52 PM

This was actually not a pull request at all, but a scheduled workflow. The latest commit included with the workflow run also appears in the pull requests of two separate forks that are using a pull request bot to synchronize commits with their fork, so GitHub includes them in the pull_requests field of the API. This also happens with pushes directly to a branch.

Suggested fix:

const pull_requests = (workflow_run.pull_requests as PullRequest[])
.map(
pull_request =>
`<${workflow_run.repository.html_url}/pull/${pull_request.number}|#${pull_request.number}> from \`${pull_request.head.ref}\` to \`${pull_request.base.ref}\``
)
.join(', ')

These lines could filter by the owner/repo of the current workflow run to ensure this PR data is for the current repo, not a fork. In our case, this should filter out all PRs attached to this workflow, and fall back to the description of the workflow run, not a PR.

PR link to GitHub api url

I'm comfortable with it!

I found a problem that when you click on a PR number, you are redirected to the URL of the API, so I checked the repository, and it seems that the following PRs are used

9cc863f

I'd like to use it, so I'd like you to type a version of tag with the above fix applied

@master branch timeout behind proxy

Screen Shot 2021-12-14 at 10 30 59

I'm getting a timeout when running the
Gamesight/slack-workflow-status@master action

Some other IPs that are erroring out:
52.192.46.121:443
52.196.128.139:443
35.73.126.78:443
35.74.58.174:443

The action WORKS when I change it from
Gamesight/slack-workflow-status**@master**
to
Gamesight/slack-workflow-status**@v1**

Also, when the action ran with "@master" on 12/1 it was still working. Sometime between 12/2 and 12/13 it started getting the timeout.

I should mention that the environment this action is running on is behind a proxy, but the proxy itself hasn't changed recently to the best of my knowledge.

For now I will just use @v1, but am interesting in knowing what changed/broke.

Resource not accessible by integration

image

/usr/bin/docker exec  some_hash sh -c "cat /etc/*release | grep ^ID"
Error: HttpError: Resource not accessible by integration
Error: Resource not accessible by integration

Also Node12 is deprecated, are you guys planning to update dependencies?

Notify only on failure?

Is it possible to configure this action to notify only if the dependent jobs have failed?

Support for Slack Bot (App) Token

It would be great if this could use a standard Slack App Bot User OAuth Token rather than passing a webhook URL.

This would allow the bot to post across several rooms and users and allow people have the legacy webhooks disabled to use this Action.

Node.js 12 actions are deprecated.

Hi

Getting warning from the workflow.

Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. Please update the following actions to use Node.js 16: Gamesight/[email protected]

Please help to fix

Add description to the hook

We would like to have another field like 'description' in the action to inject a link or an URL for reference:

- name: Slack Workflow Notification with Merged PR
  uses: Gamesight/slack-workflow-status@master
  with:
          repo_token: ${{secrets.GITHUB_TOKEN}}
          slack_webhook_url: ${{secrets.SLACK_WEBHOOK}}
          channel: 'XXX-test'
          name: Production deployment
          **description: PR linked https://github.com/XXX**
          icon_emoji: ':xxx:'
          include_jobs: true
          include_commit_message: true

Is that feasible?
Thanks

New release planned?

Hey, just wondering if there is a new version release planned for the near future? Looking to use the new Node 16 support.

Show last commit on Slack

Thanks for maintaining this action!

Would it be possible to include the last commit on Slack? For example:

Success: dcelasun's pull_request #1 from new-feature to master
Workflow: test-and-deploy #123 completed in 1m 2s
Commit: First line of commit message (096e807)

and the commit hash would be a link to the commit.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.