Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ffittschen committed Jan 5, 2021
0 parents commit 39c6801
Show file tree
Hide file tree
Showing 28 changed files with 16,002 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
coverage/
dist/
lib/
node_modules/
21 changes: 21 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},
plugins: ['@typescript-eslint', 'jest'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:jest/recommended',
'prettier/@typescript-eslint',
'plugin:prettier/recommended',
],
env: {
node: true,
es6: true,
'jest/globals': true,
},
};
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Global CODEOWNER
* @Sixt/MOBILE-MINT
Binary file added .github/assets/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
121 changes: 121 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# 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
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# 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
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
# dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# ncc
lib
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
coverage/
dist/
lib/
node_modules/
10 changes: 10 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"arrowParens": "avoid",
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Sixt

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
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.
98 changes: 98 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Post Slack Message action

This action posts an enriched Slack message to a given channel.

![Screenshot](.github/assets/screenshot.png)

## Inputs

### `github_token`
**Required** A GitHub token used to enrich the Slack message. Defaults to the one provided by the GitHub action context.

### `slack_token`
**Required** Slack authentication token bearing required scopes.

Example
```
xxxx-xxxxxxxxx-xxxx
```

### `channel`
**Required** Channel, private group, or IM channel to send message to. Can be an encoded ID, or a name.

Example
```
C1234567890
```

### `status`
**Required** The current status of the job. Defaults to the one provided by the context.

Possible values: `success`, `failure`, `cancelled`

### `mention`
A trigger word that should be used to mention a channel, a team or a user ([Reference](https://api.slack.com/reference/surfaces/formatting#mentioning-users)). When the [`text`](#text) input uses a "fake headline" (see below), the mention is injected after the newline of the first fake headline.

Example: `here` to mention the channel or `subteam^SAZ94GDB8` to mention a user group with the ID _SAZ94GDB8_.

### `if_mention`
A condition when the mention should be applied. The value can be success, failure, cancelled or always. Multiple conditions can be separated with a comma.

Example: `success,failure`

### `fields`
A list of fields that should be used to enrich the message. Not all fields might be available, e.g. if a workflow has been started with the workflow_dispatch event, it might not be possible to fetch data related to a PR. If you specify more than one field, please separate them with a comma, e.g. `commit,repo`.

Possible fields are: `repo`, `message`, `commit`, `actor`, `job`, `duration`, `eventName`, `ref`, `pr`, `workflow`.

To use all fields, you can pass `all` to this input.

### `text`
A message that can be formatted using [Slack's mrkdwn format](https://api.slack.com/reference/surfaces/formatting). By using mrkdwn, you can also achieve "fake headlines" with bold text and newlines (see example below). This input is optional if a 'header' or 'custom_blocks' input is provided. In case one of the mentioned inputs is provided as well, the 'text' will be used as fallback and as the text displayed in notifications.

Example
```
*Comment*\nThis is a comment.
```

### `header`
A header, displayed at the top of the Slack message. Supports Slack's colon emoji syntax `:tada:`.

### `changelog`
A changelog, which will be displayed within the message.

### `buttons`
A list of buttons, using new lines as separator. Each line has the format `title|url`. It is also possible to change the style of the button by inserting a style of [Slack's Button Element](https://api.slack.com/reference/block-kit/block-elements#button) between the `title` and the `url`, e.g. `title|style|url`.

Example: `Download|https://example.com/file.zip`

### `custom_blocks`
A JSON-based array of structured blocks. Setting this property will only send the custom blocks and `text` if any was provided. See [Slack Block Kit Builder](https://app.slack.com/block-kit-builder) for more information.

Example
```json
[
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Hello, Assistant to the Regional Manager Dwight! *Michael Scott* wants to know where you'd like to take the Paper Company investors to dinner tonight.\n\n *Please select a restaurant:*"
}
}
]
```

## Example usage

This example results in a message as visible in the screenshot above.

```yml
- name: Post to slack
uses: Sixt/action-slack-message@v1
with:
slack_token: ${{ secrets.SLACK_TOKEN }}
channel: C1234567890
fields: ref,actor,pr,duration
header: "Build ${{ job.status }}"
text: "*Comment*\n${{ steps.some-previous-step.outputs.comment }}"
```
Loading

0 comments on commit 39c6801

Please sign in to comment.