Skip to content

Commit

Permalink
🔧 Fix Slack Alert Failing by Only Using Commit Header
Browse files Browse the repository at this point in the history
Add some more lines

And even more lines!

And one more for good luck!
  • Loading branch information
connormaglynn committed Nov 21, 2024
1 parent 2b7d7d7 commit 8f345c6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/management-account-apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:
- run: terraform apply -auto-approve
if: github.event.ref == 'refs/heads/main'

- name: Save Commit Header
run: |
echo "COMMIT_MESSAGE_HEADER=$(git log -1 --pretty=%B | head -n 1)" >> $GITHUB_ENV
- name: Slack failure notification
if: ${{ failure() && github.ref == 'refs/heads/main' }}
uses: slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 # v1.27.0
Expand All @@ -48,7 +51,7 @@ jobs:
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":x: *GitHub Workflow Failed!* \n\nA workflow has failed in the repository *<https://github.com/${{ github.repository }}|${{ github.repository }}>*.\n\n*Workflow:* `${{ github.workflow }}`\n*Branch:* `${{ github.ref_name }}`\n*Commit:* `${{ github.sha }}` - _`${{ format(github.event.head_commit.message, 'replace', '\\n', ' ') }}`_\n*Author:* `${{ github.event.head_commit.author.name }}`"}},
"text": ":x: *GitHub Workflow Failed!* \n\nA workflow has failed in the repository *<https://github.com/${{ github.repository }}|${{ github.repository }}>*.\n\n*Workflow:* `${{ github.workflow }}`\n*Branch:* `${{ github.ref_name }}`\n*Commit:* `${{ github.sha }}` - _`${{ env.COMMIT_MESSAGE_HEADER }}`_\n*Author:* `${{ github.event.head_commit.author.name }}`"}},
{
"type": "actions",
"elements":[
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/organisation-security-apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:
- run: terraform apply -auto-approve
if: github.event.ref == 'refs/heads/main'

- name: Save Commit Header
run: |
echo "COMMIT_MESSAGE_HEADER=$(git log -1 --pretty=%B | head -n 1)" >> $GITHUB_ENV
- name: Slack failure notification
if: ${{ failure() && github.ref == 'refs/heads/main' }}
uses: slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 # v1.27.0
Expand All @@ -48,7 +51,7 @@ jobs:
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":x: *GitHub Workflow Failed!* \n\nA workflow has failed in the repository *<https://github.com/${{ github.repository }}|${{ github.repository }}>*.\n\n*Workflow:* `${{ github.workflow }}`\n*Branch:* `${{ github.ref_name }}`\n*Commit:* `${{ github.sha }}` - _`${{ format(github.event.head_commit.message, 'replace', '\\n', ' ') }}`_\n*Author:* `${{ github.event.head_commit.author.name }}`"}},
"text": ":x: *GitHub Workflow Failed!* \n\nA workflow has failed in the repository *<https://github.com/${{ github.repository }}|${{ github.repository }}>*.\n\n*Workflow:* `${{ github.workflow }}`\n*Branch:* `${{ github.ref_name }}`\n*Commit:* `${{ github.sha }}` - _`${{ env.COMMIT_MESSAGE_HEADER }}`_\n*Author:* `${{ github.event.head_commit.author.name }}`"}},
{
"type": "actions",
"elements":[
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/test-alert-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Test Alert Workflow

on:
push:
branches:
- main
pull_request:
branches:
- main
Expand All @@ -13,6 +16,10 @@ jobs:
contents: read
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Save Commit Header
run: |
echo "COMMIT_MESSAGE_HEADER=$(git log -1 --pretty=%B | head -n 1)" >> $GITHUB_ENV
- name: Slack failure notification
uses: slackapi/slack-github-action@37ebaef184d7626c5f204ab8d3baff4262dd30f0 # v1.27.0
with:
Expand Down

0 comments on commit 8f345c6

Please sign in to comment.