-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a314c90
Showing
7 changed files
with
319 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Send Slack Message | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
bambajabbi
|
||
|
||
This is a GitHub action to send a Slack message using a Slack bot token. | ||
|
||
## Set up | ||
|
||
See https://api.slack.com/bot-users for information on setting up and installing a Slack Bot. | ||
|
||
## Inputs | ||
|
||
- `message`: The Slack message to send | ||
|
||
- `slack-token`: The Slack bot user access token | ||
|
||
- `channel`: The Slack channel ID to send the message to | ||
|
||
## Example Usage | ||
|
||
|
||
```yaml | ||
- name: Post message | ||
uses: joshmgross/send-slack-message@main | ||
with: | ||
message: 'Hello world' | ||
channel: ${{ secrets.SLACK_CHANNEL_ID }} | ||
slack-token: ${{ secrets.SLACK_BOT_TOKEN }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: 'Send Slack Message' | ||
description: 'Sends a slack message' | ||
author: 'joshmgross' | ||
inputs: | ||
message: | ||
required: true | ||
description: 'The Slack message to send' | ||
slack-token: | ||
required: true | ||
description: 'A bot user access token, see https://api.slack.com/bot-users' | ||
channel: | ||
required: true | ||
description: 'The Slack channel ID' | ||
runs: | ||
using: 'node12' | ||
main: 'dist/index.js' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "send-slack-message", | ||
"version": "1.0.0", | ||
"description": "A GitHub action to send a Slack message", | ||
"main": "dist/index.js", | ||
"private": true, | ||
"scripts": { | ||
"build": "tsc", | ||
"pack": "ncc build src/index.ts" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/joshmgross/send-slack-message.git" | ||
}, | ||
"keywords": [ | ||
"Actions", | ||
"node" | ||
], | ||
"author": "joshmgross", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/joshmgross/send-slack-message.git" | ||
}, | ||
"homepage": "https://github.com/joshmgross/send-slack-message.git", | ||
"dependencies": { | ||
"@actions/core": "^1.2.6", | ||
"@slack/web-api": "^5.13.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^12.12.47", | ||
"@zeit/ncc": "^0.22.3", | ||
"typescript": "^3.9.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { WebClient } from '@slack/web-api'; | ||
import * as core from "@actions/core"; | ||
|
||
async function run(): Promise<void> { | ||
try { | ||
// Inputs and validation | ||
const slackToken = core.getInput("slack-token", { required: true }); | ||
const channel = core.getInput("channel", { required: true }); | ||
const message = core.getInput("message", { required: true }); | ||
|
||
// Send slack message | ||
const slackWebClient = new WebClient(slackToken); | ||
const result = await slackWebClient.chat.postMessage({ | ||
text: message, | ||
channel: channel | ||
}); | ||
|
||
if (result.ok) { | ||
core.info('Slack message sent 🚀') | ||
} else { | ||
core.setFailed(`❌ Unable to send Slack message: ${result.error}`); | ||
} | ||
|
||
} catch (error) { | ||
core.setFailed(`❌ Action failed with error: ${error}`) | ||
} | ||
} | ||
|
||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"compilerOptions": { | ||
/* Basic Options */ | ||
"target": "ES2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ | ||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ | ||
"outDir": "./lib", /* Redirect output structure to the directory. */ | ||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ | ||
|
||
/* Strict Type-Checking Options */ | ||
"strict": true, /* Enable all strict type-checking options. */ | ||
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ | ||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ | ||
}, | ||
"exclude": ["node_modules"] | ||
} |
this make me confeuse