From 719f718afae209cf7ee031c93e5fd041dd433b9b Mon Sep 17 00:00:00 2001 From: sangeet-joy_xero Date: Wed, 16 Oct 2024 14:10:19 +0530 Subject: [PATCH] added slack alert composite action --- .github/actions/notify-slack.yml | 46 ++++++++++++++++++++++++++++++++ .github/workflows/publish.yml | 12 ++++++--- 2 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 .github/actions/notify-slack.yml diff --git a/.github/actions/notify-slack.yml b/.github/actions/notify-slack.yml new file mode 100644 index 00000000..0210e173 --- /dev/null +++ b/.github/actions/notify-slack.yml @@ -0,0 +1,46 @@ +name: slack-alert-action +description: "Action to send slack payload to public-sdk-events channel" + +inputs: + heading_text: + required: true + alert_type: + required: true + +runs: + using: "composite" + + steps: + - name: Send slack notification + id: slack + uses: slackapi/slack-github-action@v1.27.0 + env: + SLACK_WEBHOOK_URL: "" + with: + payload: | + { + "channel": "#public-sdk-events", + "text": ${{inputs.heading_text}} + "attachments": [ + { + "color": ${{inputs.alert_type}}, + "fields": [ + { + "title": "Repository", + "value": "${{github.repository}}" + "short": true + }, + { + "title": "Job", + "value": "" + "short": true + }, + { + "title": "commit", + "value": "${{github.sha}}" + "short": true + }, + ] + } + ] + } diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 70f3dca6..7a3e3125 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -38,14 +38,18 @@ jobs: run: npm publish working-directory: xero-node - notify-slack: + notify-slack-on-success: runs-on: ubuntu-latest needs: publish + if: success() steps: - - name: Send slack notification on sucess - if: success() + - name: Send slack notification on success run: echo "Slack alert on success" + notify-slack-on-failure: + runs-on: ubuntu-latest + needs: publish + if: failure() + steps: - name: Send slack notification on failure - if: failure() run: echo "Slack alert on failure"