ravsamhq / notify-slack-action

🔔 Send a Slack Notification from Github Actions regarding failure, warnings, or even success.
https://ravsam.in/blog/send-slack-notification-when-github-actions-fails/
MIT License
173 stars 57 forks source link

Need notification for cancelled runs #41

Closed gabiganam closed 2 years ago

gabiganam commented 2 years ago

I noticed that if I cancel a running action, I don't get any Slack notification about it. I'm using if: always() on all of my notifications. Am I missing something? or is this not supported?

ravgeetdhillon commented 2 years ago

Hey @gabiganam,

Could you please share your action configuration so that I can have a better look and suggest something?

gabiganam commented 2 years ago

Of course @ravgeetdhillon :)

This action for example, is a simple action that deletes a k8s namespace when a branch is deleted:

name: Delete namespace on branch deletion
on: delete

env:
   SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

jobs:
  delete:
    if: github.event.ref_type == 'branch'
    env:
      REF: refs/heads/${{ github.event.ref }}

    runs-on: ubuntu-latest
    steps:
      - name: Slack notification
        if: always()
        uses: ravsamhq/notify-slack-action@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          status: ${{ job.status }}
          notification_title: '1/2 - Deleting namespace...'
          message_format: ''
          footer: '<{run_url}|See Action Run> | <{repo_url}|Repo {repo}> | <{workflow_url}|{workflow} Workflow>'

     <several steps redacted here>

      - name: Slack notification
        if: always()
        uses: ravsamhq/notify-slack-action@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          status: ${{ job.status }}
          notification_title: '2/2 - Namespace deleted!'
          message_format: ''
          footer: '<{run_url}|See Action Run> | <{repo_url}|Repo {repo}> | <{workflow_url}|{workflow} Workflow>'

BTW can you please take a look at this too? https://github.com/ravsamhq/notify-slack-action/issues/39 In this context for example, I have an environment variable called "namespace" that I would love to print in the Slack notification title!

ravgeetdhillon commented 2 years ago

@gabiganam Notifications for cancelled runs are now available in v2.1.0. For more details, checkout the README.

gabiganam commented 2 years ago

Thank you for both fixes!