Skip to content

Commit

Permalink
add automated slack message
Browse files Browse the repository at this point in the history
  • Loading branch information
james-jdgtl committed Dec 9, 2024
1 parent 77cb279 commit d9a1e43
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/actions/runner-slack-notification/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Run the slack notification for various things
description: This sends a slack notification

inputs:
slack_channel:
description: 'The channel to send the slack message to'
required: true
slack_bot_token:
description: 'The slack bot token'
required: true
pull_request_number:
description: The number of the pull request
required: true
runs:
using: composite
steps:
- name: Slack - Send a message
id: slack-message
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0
with:
method: chat.postMessage
token: ${{ inputs.slack_bot_token }}
payload: |
"channel": "${{ inputs.slack_channel }}",
"text": "*GITHUB ACTIONS RUNNER*: upgrade PR has been created for *${{ github.event.repository.name }}*",
"blocks": [
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Github Actions Runner PR - new runner available*"
}
]
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Pull Request:*\n<${{ github.server_url }}/${{ github.repository }}/pull/${{ inputs.pull_request_number }}/files|${{ github.event.repository.name }}/pull/${{ inputs.pull_request_number }}>"
}
]
}
]
26 changes: 26 additions & 0 deletions .github/workflows/new_renovate_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: New PR created - Slack message if it's a renovate Dockerfile PR

on:
pull_request:
types: [opened, reopened]

jobs:
renovate_pr:
runs-on: [ ubuntu-latest ]
permissions:
contents: write
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Get PR details
id: get_pr_details
run: |
echo "::set-output name=title::$(jq -r .pull_request.title < $GITHUB_EVENT_PATH)"
echo "::set-output name=number::$(jq -r .pull_request.number < $GITHUB_EVENT_PATH)"
- name: Run action if PR title contains 'actions/runner'
if: contains(steps.get_pr_details.outputs.title, 'actions/runner')
uses: ./.github/actions/runner-slack-notification
with:
slack_channel: ${{ vars.NOTIFICATIONS_SLACK_CHANNEL }}
slack_bot_token: ${{ secrets.HMPPS_SRE_SLACK_BOT_TOKEN }}
pull_request_number: ${{ steps.get_pr_details.outputs.number }}

0 comments on commit d9a1e43

Please sign in to comment.