Part of my Github action pipeline is to notify a Slack channel on successful deployment. Within that notification, a hyperlink to the Github PR is injected. The issue is the hyperlink shows the full text of the URL, and not a specified (shorter) name.
Instead of showing the full link like this: https://github.com/CompanyABC/repo1/pull/8
...I want to show something like this: My PR
So it's the same link, but just given a custom name. Here is the relevant part of my Github action pipeline script:
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: ${{ job.status }} # or a specific color like 'good' or '#ff00ff'
SLACK_MESSAGE: "GitHub build result: ${{ job.status }}\nPR Title: ${{ github.event.pull_request.title }}\nPR link: ${{ github.event.pull_request.html_url || github.event.head_commit.url }}"
SLACK_TITLE: Deployment successfully completed
SLACK_USERNAME: ${{ github.actor }}
SLACK_WEBHOOK: ${{ secrets.DEVOPS_NONPROD_RELEASES_SLACK_WEBHOOK }}
Notice what I have defined for the SLACK_MESSAGE attribute. Is there some way in the action script of combining this:
github.event.pull_request.title
...and this:
github.event.pull_request.html_url
...to yield me this:
...instead of this:
PR Title: MY PR, PR link: https://github.com/CompanyABC/repo1/pull/8
?
Kinda like how this would work in regular web development:
<a href="https://github.com/CompanyABC/repo1/pull/8">My PR</a>