Skip to content

Commit

Permalink
[#3] Merge branch 'master' into v3
Browse files Browse the repository at this point in the history
  • Loading branch information
8398a7 committed Apr 5, 2020
2 parents 1970e54 + ba96289 commit 0374742
Show file tree
Hide file tree
Showing 11 changed files with 249 additions and 179 deletions.
19 changes: 9 additions & 10 deletions .github/workflows/slack-mainline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,42 @@ name: Slack Mainline
on:
push:
branches:
- master
- v2
- v3

jobs:
notification:
runs-on: ubuntu-latest
steps:
- name: Succeeded Check
uses: 8398a7/action-slack@v2
uses: 8398a7/action-slack@v3
with:
status: success
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_FOR_INTEGRATION_TEST }}
- name: Failed Check
uses: 8398a7/action-slack@v2
uses: 8398a7/action-slack@v3
with:
status: failure
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_FOR_INTEGRATION_TEST }}
- name: Cancelled Check
uses: 8398a7/action-slack@v2
uses: 8398a7/action-slack@v3
with:
status: cancelled
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_FOR_INTEGRATION_TEST }}
- name: Check
uses: 8398a7/action-slack@v2
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_FOR_INTEGRATION_TEST }}
- name: Legacy Check
uses: 8398a7/action-slack@v2
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
username: legacy user
Expand All @@ -47,10 +46,10 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_LEGACY_WEBHOOK_URL_FOR_INTEGRATION_TEST }}
- name: Custom Field Check
uses: 8398a7/action-slack@v2
uses: 8398a7/action-slack@v3
with:
status: custom
payload: |
custom_payload: |
{
text: "Custom Field Check",
attachments: [{
Expand Down Expand Up @@ -82,7 +81,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_FOR_INTEGRATION_TEST }}
- name: Check
uses: 8398a7/action-slack@v2
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- uses: 8398a7/action-slack@v2
- uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
env:
Expand Down
142 changes: 10 additions & 132 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,140 +6,18 @@
![](https://img.shields.io/github/v/release/8398a7/action-slack?color=brightgreen)
[![codecov](https://codecov.io/gh/8398a7/action-slack/branch/master/graph/badge.svg)](https://codecov.io/gh/8398a7/action-slack)

You can notify slack of GitHub Actions.
For v3 or later under development, write the document [here](https://action-slack.netlify.com).

## Usage

See [action.yml](action.yml), [test.yml](.github/workflows/test.yml)

### with Parameters

| key | value | default | description |
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ----------------------------------------------------------------------------------------------------------- |
| status | 'success' or 'failure' or 'cancelled' or 'custom' | '' | Recommend<br />`${{ job.status }}`. |
| text | any string | '' | You can add to text by specifying it. |
| author_name | any string | '8398a7@action-slack' | It can be overwritten by specifying. The job name is recommend. |
| mention | 'here' or 'channel' or [user_id](https://api.slack.com/reference/surfaces/formatting#mentioning-users) (e.g. `mention: user_id,user_id2`) | '' | Always mention when specified. |
| only_mention_fail | 'here' or 'channel' or [user_id](https://api.slack.com/reference/surfaces/formatting#mentioning-users) (e.g. `mention: user_id,user_id2`) | '' | If specified, mention only on failure. |
| payload | e.g. `{"text": "Custom Field Check", obj: 'LOWER CASE'.toLowerCase()}` | '' | Only available when status: custom. The payload format can pass javascript object. |
| username | Only legacy incoming webhook supported. | '' | override the legacy integration's default name. |
| icon_emoji | Only legacy incoming webhook supported. | '' | an [emoji code](https://www.webfx.com/tools/emoji-cheat-sheet/) string to use in place of the default icon. |
| icon_url | Only legacy incoming webhook supported. | '' | an icon image URL string to use in place of the default icon. |
| channel | Only legacy incoming webhook supported. | '' | override the legacy integration's default channel. This should be an ID, such as `C8UJ12P4P`. |

See here for `payload` reference or [Custom Notification](https://github.com/8398a7/action-slack#custom-notification).

- [Message Formatting](https://api.slack.com/docs/messages/builder)
- Enter json and check in preview.
- [Reference: Message payloads](https://api.slack.com/reference/messaging/payload)

### Notification

<img width="480" alt="success" src="https://user-images.githubusercontent.com/8043276/64882150-7c942480-d697-11e9-9fc8-85e6c02f6aeb.png">
- [Document](https://action-slack.netlify.com)

```yaml
- uses: 8398a7/action-slack@v2
with:
status: ${{ job.status }}
author_name: Integration Test # default: 8398a7@action-slack
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
if: always() # Pick up events even if the job fails or is canceled.
steps:
- uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
if: always() # Pick up events even if the job fails or is canceled.
```
When adding to text, write as follows.
```yaml
- uses: 8398a7/action-slack@v2
with:
status: ${{ job.status }}
text: overwrite text
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
```
In case of failure or cancellation, you will be notified as follows.
<img width="483" alt="failure" src="https://user-images.githubusercontent.com/8043276/64882189-933a7b80-d697-11e9-8afc-56530176a15e.png">
<img width="484" alt="cancelled" src="https://user-images.githubusercontent.com/8043276/64882212-a3525b00-d697-11e9-8e98-aa5e515b304f.png">
#### Legacy Incoming Webhooks
If you specify as follows, you can also support legacy incoming webhooks.
The specified `secrets.SLACK_WEBHOOK_URL` must be legacy.

```yaml
- uses: 8398a7/action-slack@v2
with:
type: ${{ job.status }}
username: Custom Username
icon_emoji: ':octocat:'
channel: '#integration-test'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
```

### Custom Notification

Use `status: custom` if you want to send an arbitrary payload.
The payload format can pass javascript object.

<img width="401" alt="custom" src="https://user-images.githubusercontent.com/8043276/64948009-1aaf0700-d8b1-11e9-868e-00be274821cf.png">

```yaml
- uses: 8398a7/action-slack@v2
with:
status: custom
payload: |
{
text: "Custom Field Check",
attachments: [{
"author_name": "8398a7@action-slack", // json
fallback: 'fallback',
color: 'good',
title: 'CI Result',
text: 'Succeeded',
fields: [{
title: 'lower case',
value: 'LOWER CASE CHECK'.toLowerCase(),
short: true
},
{
title: 'reverse',
value: 'gnirts esrever'.split('').reverse().join(''),
short: true
},
{
title: 'long title1',
value: 'long value1',
short: false
}],
actions: [{
}]
}]
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
```

## Next Action

### Selectable Field

Currently the field is fixed, but I want to make it selectable.
It is assumed that the input is in csv format.

```yaml
- uses: 8398a7/action-slack@v2
with:
status: ${{ job.status }}
fields: repo,message,action,author
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
```
<img width="480" alt="success" src="https://user-images.githubusercontent.com/8043276/78500565-2b15c900-7792-11ea-86fe-a0dcf7ebef84.png" />
3 changes: 2 additions & 1 deletion docs/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ const config = {
forcedNavOrder: [
'/usage',
'/with',
'/migration',
'/usecase',
'/next_action',
'/contributors',
],
collapsedNav: [
'/usecase', // add trailing slash if enabled above
'/migration',
],
links: [{ text: 'GitHub', link: 'https://github.com/8398a7/action-slack' }],
frontline: false,
Expand Down
19 changes: 12 additions & 7 deletions docs/content/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ metaDescription: You can notify slack of GitHub Actions.
You can notify slack of GitHub Actions.

- [Usage](/usage)
- [v2 Document Link](https://github.com/8398a7/action-slack/blob/v2/README.md)

# Caution
```yaml
steps:
- uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
if: always() # Pick up events even if the job fails or is canceled.
```
This is a v3 document under development.
We are currently releasing v2 as a stable version.

See [here](https://github.com/marketplace/actions/action-slack) for v2 documentation.

<img width="480" alt="logo" src="./logo.png" />
<img width="480" alt="success" src="https://user-images.githubusercontent.com/8043276/78500565-2b15c900-7792-11ea-86fe-a0dcf7ebef84.png" />
5 changes: 5 additions & 0 deletions docs/content/migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Migration
metaTitle: Migration | action-slack
metaDescription: This page describes how to update the major version.
---
Loading

0 comments on commit 0374742

Please sign in to comment.