Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fragnarok/notify-action
GitHub action to send an IFTTT notification
https://github.com/fragnarok/notify-action
Last synced: 26 days ago
JSON representation
GitHub action to send an IFTTT notification
- Host: GitHub
- URL: https://github.com/fragnarok/notify-action
- Owner: FragnaroK
- License: mit
- Created: 2023-11-08T14:10:45.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-15T11:14:54.000Z (about 1 year ago)
- Last Synced: 2023-11-15T12:27:08.045Z (about 1 year ago)
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
NotifY (IFTTT Integration Notification Action)
=====================================This GitHub Action allows you to send notifications to IFTTT based on different events in your repository. (using Webhooks)
Inputs
------### `type` (required)
Notification type (Success, Error, Pending, Warning, Info, Debug)
### `repoName` (required)
Repository name
### `branch`
Branch name
### `details`
Notification message
### `repoLink`
Repository link
### `IFTTT_EVENT`
IFTTT event name (default: 'ga\_notify')
### `IFTTT_KEY` (required)
IFTTT key
### `HEADER`
IFTTT header (default: '{"Content-Type": "application/json"}')
Usage
-----
```yaml
name: Your Workflow
on:
push:
branches:
- main
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Notify IFTTT
uses: fragnarok/notify-action@v2
with:
type: 'error'
repoName: 'exampleRepo'
branch: 'main'
details: 'Workflow failed!'
repoLink: 'https://github.com/user/repo'
IFTTT_KEY: ${{ secrets.IFTTT_KEY }}
```The Object sent to IFTTT will look like this:
```json
{
"status": "error",
"repoName": "YourRepoName",
"repoBranch": "main",
"repoLink": "https://github.com//",
"details": "Workflow failed!",
}
```A possible way to handle this data in IFTTT could be:
> Filter code once the event is received
```typescript
type GAStatus = 'error' | 'success' | 'warning' | 'pending' | 'debug' | 'info';
interface GANotification {
icon: string;
repoName: string;
status?: GAStatus;
repoBranch?: string;
repoLink?: string;
details?: string;
}function getIcon(status: GAStatus) {
switch (status.toLocaleLowerCase()) {
case 'error':
return '❌';
case 'success':
return '✅';
case 'warning':
return '⚠️';
case 'pending':
return '⏱️';
case 'debug':
return '🔨';
case 'info':
return '❕';
default:
return '🤖';
}
}function parsePayload(payload: string) {
const parsedJSON = JSON.parse(payload);const parsedNotification: GANotification = {
icon: getIcon(parsedJSON.status ? parsedJSON.status : 'info'),
status: (parsedJSON.status ? parsedJSON.status : 'info').toLocaleUpperCase(),
repoName: parsedJSON.repoName.toLocaleUpperCase(),
repoBranch: parsedJSON.repoBranch,
repoLink: parsedJSON.repoLink,
details: parsedJSON.details,
};return parsedNotification;
}function main() {
const {
icon,
status,
repoName,
repoBranch,
repoLink,
details
} = parsePayload(MakerWebhooks.jsonEvent.JsonPayload);Telegram.sendMessage.setText(`
${icon} ${status} - ${repoName} (${repoBranch}
)${details}
`)
}main();
```Feel free to customize the workflow to fit your specific use case.