From 267136c20b60762ad72a99830fdac1e0c2b2fa9e Mon Sep 17 00:00:00 2001 From: Niloofar Date: Mon, 25 Mar 2024 14:24:53 +0800 Subject: [PATCH] ci: created slack notification action --- .../send_slack_notification/action.yml | 34 +++++++++++++++++++ .github/workflows/release.yaml | 30 +++++++--------- 2 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 .github/actions/send_slack_notification/action.yml diff --git a/.github/actions/send_slack_notification/action.yml b/.github/actions/send_slack_notification/action.yml new file mode 100644 index 0000000000..53bc7b368c --- /dev/null +++ b/.github/actions/send_slack_notification/action.yml @@ -0,0 +1,34 @@ +name: send_slack_notification +description: Send custom JSON data to Slack workflow +inputs: + SLACK_WEBHOOK_URL: + description: 'Slack webhook URL' + required: true + MESSAGE: + description: 'Status message' + required: true + +runs: + using: composite + steps: + - name: Send custom JSON data to Slack workflow + env: + SLACK_WEBHOOK_URL: ${{ inputs.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + MESSAGE: ${{ inputs.MESSAGE }} + + uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 # v1.25.0 + with: + # For posting a rich message using Block Kit + payload: | + { + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ${{ env.MESSAGE }} + } + } + ] + } diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 94bbb9360c..573e09ecd6 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -58,23 +58,17 @@ jobs: https://api.github.com/repos/${{github.repository}}/actions/workflows/$QUILL_ICONS_PARK_WORK_FLOW_FILE/dispatches \ -d '{"ref":"main"}' - - name: Send Release Slack notification - uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 # v1.25.0 + - name: Create Slack Message + id: create_slack_message + run: | + if [ $WORKFLOW_CONCLUSION == "success" ]; then + echo "MESSAGE=$RELEASE_TYPE ✅ The release for @deriv/quill-icons was successful, and the new version (${{ steps.extract_version.outputs.RELEASE_VERSION }}) is now available." >> $GITHUB_OUTPUT + else + echo "MESSAGE=$RELEASE_TYPE 🤨 The release attempt for @deriv/quill-icons with version ${{ steps.extract_version.outputs.RELEASE_VERSION }} was unsuccessful." >> $GITHUB_OUTPUT + fi + + - name: Send Slack Notification + uses: './.github/actions/send_slack_notifications' with: - # For posting a rich message using Block Kit - payload: | - { - "text": "@deriv/quill-icons", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "@deriv/quill-icons@v${{ steps.extract_version.outputs.RELEASE_VERSION }} release: ${{ job.status }}" - } - } - ] - } - env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + MESSAGE: ${{ steps.create_slack_message.outputs.MESSAGE }}