Skip to content

Commit

Permalink
Merge branch 'release/v2.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
zenopopovici committed Jan 22, 2024
2 parents 3e536e0 + e7a070d commit f439583
Show file tree
Hide file tree
Showing 11 changed files with 4,587 additions and 26,997 deletions.
56 changes: 37 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,74 @@
name: "Build & Test"
on: # rebuild any PRs and main branch changes
name: graffino-teams-notification-test
run-name: ${{ github.actor }} is performing a Graffino Teams Notification test build
on:
repository_dispatch:
pull_request:
push:
branches:
- master
- 'releases/*'

- "master"

jobs:
build: # make sure build/ci work properly
runs-on: ubuntu-latest
build:
runs-on: [self-hosted, graffino]
strategy:
matrix:
os: [ubuntu-latest]
node: [18]
steps:
- uses: actions/checkout@v1
- run: |
npm install
npm run all
test: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest
- name: Checkout
id: Checkout
uses: actions/checkout@v4

- uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}

- name: Install NPM Packages
if: success()
run: |
yarn install
- name: Build Frontend
if: success()
run: |
yarn run build
test:
runs-on: [self-hosted, graffino]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: ./
with:
github-token: ${{ github.token }}
ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
notification-summary: Deployment Started
notification-color: 17a2b8
timezone: America/Denver
timezone: Bucharest/Romania
- uses: ./
with:
github-token: ${{ github.token }}
ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
notification-summary: Warning! Something Not Quite Right
notification-color: ffc107
timezone: America/Denver
timezone: Bucharest/Romania
- uses: ./
with:
github-token: ${{ github.token }}
ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
notification-summary: OMG!! Something Exploded
notification-color: dc3545
timezone: America/Denver
timezone: Bucharest/Romania
- uses: ./
with:
github-token: ${{ github.token }}
ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
notification-summary: Whew! Everything is right with the world again!
notification-color: 28a745
timezone: America/Denver
timezone: Bucharest/Romania
- uses: ./
with:
github-token: ${{ github.token }}
ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
notification-summary: "Emojify! &#x1F6A2​​ ✅"
notification-color: 28a745
timezone: America/Denver
timezone: Bucharest/Romania
100 changes: 2 additions & 98 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,99 +1,3 @@
# Dependency directory
node_modules

# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# OS metadata
.DS_Store
Thumbs.db

# Ignore built ts files
__tests__/runner/*
lib/**/*
dist
lib
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

The MIT License (MIT)
# The MIT License (MIT)

Copyright (c) 2018 GitHub, Inc. and contributors

Expand All @@ -19,4 +19,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
37 changes: 18 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<p align="center">
<a href="https://github.com/jdcargile/ms-teams-notification/actions"><img alt="ms-teams-notification status" src="https://github.com/jdcargile/ms-teams-notification/workflows/Build%20&%20Test/badge.svg"></a>
</p>
# Microsoft Teams Notification

![Build Status](https://github.com/Graffino/Graffino-Teams-Notification/workflows/graffino-teams-notification-test/badge.svg)

# Microsoft Teams Notification
A GitHub Action that sends customizable notifications to a dedicated Microsoft Teams channel.

## Usage

1. Add `MS_TEAMS_WEBHOOK_URI` on your repository's configs on Settings > Secrets. It is the [Webhook URI](https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook) of the dedicated Microsoft Teams channel for notification.

2) Add a new `step` on your workflow code below `actions/checkout@v2`:
2. Add a new `step` on your workflow code below `actions/checkout@v2`:

```yaml
name: MS Teams Notification
name: Graffino Teams Notification

on: [push, pull_request]

Expand All @@ -20,36 +20,35 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
# this is the new step using the ms-teams-notification action
- uses: actions/checkout@v4
- name: Notify dedicated teams channel
uses: jdcargile/[email protected]
uses: Graffino/Graffino-Teams-Notification@v2
with:
github-token: ${{ github.token }} # this will use the runner's token.
github-token: ${{ github.token }}
ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
notification-summary: Your custom notification message
notification-color: 17a2b8
timezone: America/Denver
timezone: Bucharest/Romania
```
3. Make it your own with the following configurations.
- `github-token` - (required), set to the following:
- `${{ github.token }}`
- `webhook-uri` - (required), setup a new secret to store your Microsoft Teams Webhook URI (ex. `MS_TEAMS_WEBHOOK_URI`). Learn more about setting up [GitHub Secrets](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets) or [Microsoft Teams Incoming Webhook](https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook).
- `notification-summary` (required), Your custom notification message (ex. Deployment Started or Build Successful)
- `notification-color` (optional), Custom color to help distinguish type of notification. Can be any [HEX color](https://html-color.codes/). (ex. **007bff** or **17a2b8** for info, **28a745** success, **ffc107** warning, **dc3545** error, etc.)
- `notification-color` (optional), Custom color to help distinguish type of notification. Can be any [HEX color](https://html-color.codes/). (ex. **007bff** or **17a2b8** for info, **28a745** success, **ffc107** warning, **dc3545** error, etc.)
- `timezone` - (optional, defaults to `UTC`), a [valid database timezone name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones), (ex. Australia/Sydney or America/Denver, etc.)
- `timeout` - (optional, defaults to 5s), this prevents action from getting stuck when Teams WebHooks misbehave.
- `job` - (automatically pulled from GitHub Actions), contains the stringified object for the current job, used to get the job status and display notification accordingly.

## Examples

As you can see below, the `notification-summary` and `notification-color` are being used to customize the appearance of the message. Use bright vibrant colors to notify your Microsoft Teams channel of warnings or errors in your GitHub Actions workflow.

<p align="center">
<img src="notification-color-screenshots.png">
</p>
![Notification screenshot](notification-color-screenshots.png)

### Emojis
Emoji support isn't great for incoming webhooks on Microsoft Teams yet. You can hack your way through it using HEX codes. For example, in `notification-summary` I used `Emojify! &#x1F6A2​​ &#x2705;` for the following screenshot. HEX codes for emojis [here](https://apps.timwhitlock.info/emoji/tables/unicode).

<p align="center">
<img src="notification-emoji-screenshot.png">
</p>
Emoji support isn't great for incoming webhooks on Microsoft Teams yet. You can hack your way through it using HEX codes. For example, in `notification-summary` I used `Emojify! &#x1F6A2​​ &#x2705;` for the following screenshot. HEX codes for emojis [here](https://apps.timwhitlock.info/emoji/tables/unicode).

![Notification screenshot](notification-emoji-screenshot.png)
10 changes: 8 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ inputs:
description: 'Color of notification header line'
required: true
timezone:
description: 'Timezone (ex. America/Denver)'
description: 'Timezone (ex. Bucharest/Romania)'
required: false
timeout:
description: 'Period after which the action will timeout (in milliseconds) with an error if the notification is not sent'
required: false
job:
description: 'The stringified job object, used to get the job status and display notification accordingly'
required: false
runs:
using: 'node12'
using: 'node20'
main: 'dist/index.js'
Loading

0 comments on commit f439583

Please sign in to comment.