Skip to content
This repository was archived by the owner on Sep 24, 2020. It is now read-only.

Commit a878686

Browse files
committed
Compile code to single .js file
1 parent aff91a4 commit a878686

File tree

6 files changed

+872
-2
lines changed

6 files changed

+872
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

action.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: 'Notification'
2+
description: 'Send GitHub Actions pipelines status to Discord.'
3+
inputs:
4+
webhook_url:
5+
description: 'Discord webhook URL'
6+
required: true
7+
runs:
8+
using: 'node12'
9+
main: 'dist/index.js'

index.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const core = require('@actions/core')
2+
const discord_webhook = require('./webhook')
3+
4+
async function run() {
5+
try {
6+
const discord_webhook_url = core.getInput('webhook_url', { required: true });
7+
8+
console.log(discord_webhook_url);
9+
discord_webhook(discord_webhook_url)
10+
11+
}
12+
catch (error) {
13+
core.setFailed(error.message);
14+
}
15+
}
16+
17+
run()

package.json

+12-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,19 @@
33
"description": "GitHub Action for sending notification to Discord Server over webhooks.",
44
"version": "0.0.1",
55
"main": "index.js",
6+
"scripts": {
7+
"package": "./node_modules/.bin/ncc build index.js -o dist"
8+
},
69
"author": {
710
"name": "Yashu Mittal",
811
"email": "[email protected]"
912
},
10-
"license": "MIT"
11-
}
13+
"license": "MIT",
14+
"dependencies": {
15+
"@actions/core": "^1.2.0"
16+
},
17+
"devDependencies": {
18+
"@zeit/ncc": "^0.20.5",
19+
"eslint": "^6.6.0"
20+
}
21+
}

webhook.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const webhook = (url, data) => {
2+
var xmlhttp = new XMLHttpRequest()
3+
xmlhttp.open("POST", url, true);
4+
xmlhttp.setRequestHeader(
5+
"Content-type",
6+
"application/json; charset=UTF-8"
7+
);
8+
xmlhttp.send(JSON.stringify(data));
9+
}

0 commit comments

Comments
 (0)