Skip to content

Commit

Permalink
Merge branch 'pr/34'
Browse files Browse the repository at this point in the history
  • Loading branch information
jdcargile committed Feb 21, 2024
2 parents e38bccc + 781c1bb commit c4a1019
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
notification-summary: Your custom notification message
notification-color: 17a2b8
timezone: America/Denver
verbose-logging: true
```
3. Make it your own with the following configurations.
Expand All @@ -39,6 +40,7 @@ jobs:
- `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.)
- `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.)
- `verbose-logging` - (optional, defaults to `false`), Emits additional logging showing the sent message card and response from the webhook.

## 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.
Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ inputs:
timezone:
description: 'Timezone (ex. America/Denver)'
required: false
verbose-logging:
description: 'Enable verbose logging'
default: 'false'
required: false
runs:
using: 'node20'
main: 'dist/index.js'
main: 'dist/index.js'
10 changes: 7 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async function run(): Promise<void> {
core.getInput('notification-summary') || 'GitHub Action Notification'
const notificationColor = core.getInput('notification-color') || '0b93ff'
const timezone = core.getInput('timezone') || 'UTC'

const verboseLogging = core.getInput('verbose-logging')
const timestamp = moment()
.tz(timezone)
.format('dddd, MMMM Do YYYY, h:mm:ss a z')
Expand Down Expand Up @@ -55,12 +55,16 @@ async function run(): Promise<void> {
timestamp
)

console.log(messageCard)
if (verboseLogging) {
console.log(messageCard)
}

axios
.post(msTeamsWebhookUri, messageCard)
.then(function (response) {
console.log(response)
if (verboseLogging) {
console.log(response)
}
core.debug(response.data)
})
.catch(function (error) {
Expand Down

0 comments on commit c4a1019

Please sign in to comment.