Skip to content

Commit

Permalink
Adds notifications to CI workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesduncombe committed Oct 30, 2023
1 parent 0e49dd2 commit 7f8ecf0
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 25 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/notify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Reusable Mattermost notify

on:
workflow_call:
inputs:
body-text:
required: true
type: string
icon-emoji:
type: string
default: ":wrench:"

jobs:
notify:
name: "Notify"
runs-on: ubuntu-latest

steps:
- name: "Notify"
run: |-
curl -X POST -H 'Content-Type: application/json' \
-d '{"username": "github-ci", "icon_emoji": "${{ inputs.icon-emoji }}", "text": "${{ inputs.body-text }}", "channel": "fast-platform-monitoring"}' \
${{ secrets.MATTERMOST_HOOK }}
69 changes: 44 additions & 25 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,50 @@ on: push
jobs:
# Main test job.
test:
name: "Tests"
runs-on: ubuntu-20.04

steps:
- name: Checkout the code
uses: actions/checkout@v3

- name: Setup Nodejs
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install deps
run: |
. ./.env
yarn
- name: Test coverage
run: |
. ./.env
yarn coverage
- name: Upload coverage report
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
files: ./coverage.json
verbose: true
- name: Checkout the code
uses: actions/checkout@v3

- name: Setup Nodejs
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install deps
run: |
. ./.env
yarn
- name: Test coverage
run: |
. ./.env
yarn coverage
- name: Upload coverage report
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
files: ./coverage.json
verbose: true

notify-test-failure:
name: "Notify Test failure"
needs: test
uses: ./.github/workflows/notify.yml
secrets: inherit
if: ${{ failure() }}
with:
body-text: "`${{ github.repository }}` branch: `${{ github.ref_name }}` [failed](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) :boom:"

notify-test-success:
name: "Notify Test success"
needs: test
uses: ./.github/workflows/notify.yml
secrets: inherit
if: ${{ success() }}
with:
body-text: "`${{ github.repository }}` branch: `${{ github.ref_name }}` [tested successfully](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) :tada:"

0 comments on commit 7f8ecf0

Please sign in to comment.