rtCamp/action-slack-notify

Update Slack message to use PR title

Closed this issue · 3 comments

Update Slack message to use PR title

I would like this too!

You can use a env variable like this:

env:
      PR_TITLE: ${{ github.event.pull_request.title || 'main' }}
      PR_URL: https://github.com/[ORG]/[REPO]/pull/${{ github.event.number }}

Then use it in the title (or wherever):

      - name: Notify
        uses: rtCamp/action-slack-notify@v2
        env:
          SLACK_WEBHOOK: ${{ secrets.YOUR_SECRET }}
          SLACK_USERNAME: Build Bot
          SLACK_ICON_EMOJI: ":building_construction:"
          SLACK_TITLE: CI started 🎬
          SLACK_MESSAGE: CI build for `${{ env.PR_TITLE }}` (${{ env.PR_URL }}) has started
          SLACK_FOOTER: CI runner
          SLACK_CHANNEL: [CHANNEL]
          MSG_MINIMAL: true

Thanks to @scflode for answering. You can manually set the message for this use-case, containing the pull request title and url, as mentioned above.