From 5529ad7b9b881c7ec74df58ef618347eaddc9e4a Mon Sep 17 00:00:00 2001 From: Wim Date: Thu, 2 May 2024 10:13:42 +0200 Subject: [PATCH] feat: allow usage of custom message in the slack message --- .github/workflows/notify-slack-end.yml | 5 ++++- .github/workflows/notify-slack-start.yml | 5 ++++- README.md | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/notify-slack-end.yml b/.github/workflows/notify-slack-end.yml index c72f60c..f472cfa 100644 --- a/.github/workflows/notify-slack-end.yml +++ b/.github/workflows/notify-slack-end.yml @@ -2,6 +2,9 @@ name: Release on: workflow_call: inputs: + message: + required: false + type: string channel: required: true type: string @@ -47,7 +50,7 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "*${{ github.event.repository.name }} - Action - ${{ github.workflow }}* \n <${{ github.event.repository.url }}/commit/${{ github.sha }} | ${{ env.cut_sha }}> (<${{ github.event.repository.url }}/actions/runs/${{ github.run_id }} | open>)" + "text": "*${{ inputs.message && inputs.message || github.event.repository.name }} - ${{ github.workflow }}* \n <${{ github.event.repository.url }}/commit/${{ github.sha }} | ${{ env.cut_sha }}> (<${{ github.event.repository.url }}/actions/runs/${{ github.run_id }} | open>)" } }, { diff --git a/.github/workflows/notify-slack-start.yml b/.github/workflows/notify-slack-start.yml index 82c8a78..6bf4aae 100644 --- a/.github/workflows/notify-slack-start.yml +++ b/.github/workflows/notify-slack-start.yml @@ -2,6 +2,9 @@ name: Release on: workflow_call: inputs: + message: + required: false + type: string channel: required: true type: string @@ -45,7 +48,7 @@ jobs: "type": "section", "text": { "type": "mrkdwn", - "text": "*${{ github.event.repository.name }} - Action - ${{ github.workflow }}* 🚀 \n <${{ github.event.repository.url }}/commit/${{ github.sha }} | ${{ env.cut_sha }}> (<${{ github.event.repository.url }}/actions/runs/${{ github.run_id }} | open>)" + "text": "*${{ inputs.message && inputs.message || github.event.repository.name }} - ${{ github.workflow }}* 🚀 \n <${{ github.event.repository.url }}/commit/${{ github.sha }} | ${{ env.cut_sha }}> (<${{ github.event.repository.url }}/actions/runs/${{ github.run_id }} | open>)" } }, { diff --git a/README.md b/README.md index 1f3d7fe..ea7569b 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ jobs: secrets: slackToken: ${{ secrets.SLACK_BOT_RELEASE_TOKEN}} with: + message: CUSTOM_MESSAGE (optional if no message is provided, the repository name will be used) channel: YOUR_CHANNEL_TO_POST_MESSAGES notifyOnlyOnFailure: boolean @@ -39,6 +40,7 @@ jobs: with: time: ${{ needs.notify-start.outputs.time }} result: ${{ needs.release.result }} + message: CUSTOM_MESSAGE (optional if no message is provided, the repository name will be used) channel: YOUR_CHANNEL_TO_POST_MESSAGES notifyOnlyOnFailure: boolean ```