This commit is contained in:
839 2020-06-28 22:23:51 +09:00
Родитель fd0c769355
Коммит a51e685b8d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B320DBCCE13B7629
8 изменённых файлов: 198 добавлений и 57 удалений

Просмотреть файл

@ -9,6 +9,10 @@
- [Document](https://action-slack.netlify.com)
## Quick Start
You can learn more about it [here](https://action-slack.netlify.com/usecase/01-general).
```yaml
steps:
- uses: 8398a7/action-slack@v3
@ -22,3 +26,29 @@ steps:
```
<img width="495" alt="success" src="https://user-images.githubusercontent.com/8043276/84587112-64844800-ae57-11ea-8007-7ce83a91dae3.png" />
## Custom Formats of your choice
You can learn more about it [here](https://action-slack.netlify.com/usecase/02-custom).
```yaml
steps:
- uses: 8398a7/action-slack@v3
with:
status: custom
fields: all
custom_payload: |
{
username: 'action-slack',
icon_emoji: ':octocat:',
attachments: [{
color: 'good',
text: `${process.env.AS_WORKFLOW}\n${process.env.AS_JOB} (${process.env.AS_COMMIT}) of ${process.env.AS_REPO}@master by ${process.env.AS_AUTHOR} succeeded in ${process.env.AS_TOOK}`,
}]
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_LEGACY_WEBHOOK_URL_FOR_INTEGRATION_TEST }}
```
<img width="633" alt="custom" src="https://user-images.githubusercontent.com/8043276/85947865-3723b800-b988-11ea-80f7-6db5329c6af7.png">

Просмотреть файл

@ -23,11 +23,8 @@ const config = {
},
},
sidebar: {
forcedNavOrder: ['/usage', '/with', '/migration', '/usecase', '/contributors'],
collapsedNav: [
'/usecase', // add trailing slash if enabled above
'/migration',
],
forcedNavOrder: ['/usage', '/with', '/fields', '/migration', '/usecase', '/contributors'],
collapsedNav: ['/usecase', '/migration'],
links: [{ text: 'GitHub', link: 'https://github.com/8398a7/action-slack' }],
frontline: false,
ignoreIndex: true,

44
docs/content/fields.md Normal file
Просмотреть файл

@ -0,0 +1,44 @@
---
title: Fields
metaTitle: Fields | action-slack
metaDescription: This explains the values that can be specified in Fields.
---
If you have more than one, please enter it in csv format.
Corresponding types are as follows.
<img width="495" alt="success" src="https://user-images.githubusercontent.com/8043276/84587112-64844800-ae57-11ea-8007-7ce83a91dae3.png" />
| Field | Required `GITHUB_TOKEN` | Environment Variable | Description |
| --------- | ----------------------- | -------------------- | ------------------------------------- |
| repo | no | `AS_REPO` | A working repository name |
| commit | no | `AS_COMMIT` | commit hash |
| eventName | no | `AS_EVENT_NAME` | trigger event name |
| ref | no | `AS_REF` | git refrence |
| workflow | no | `AS_WORKFLOW` | GitHub Actions workflow name |
| message | yes | `AS_MESSAGE` | commit message |
| author | yes | `AS_AUTHOR` | The author who pushed |
| job | yes | `AS_JOB` | The name of the job that was executed |
| took | yes | `AS_TOOK` | Execution time for the job |
```yaml
steps:
- uses: 8398a7/action-slack@v3
with:
fields: repo,commit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
```
If you want all items, specify `all`.
```yaml
steps:
- uses: 8398a7/action-slack@v3
with:
fields: all
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
```

Просмотреть файл

@ -1,7 +1,10 @@
---
title: Usecase
metaTitle: Usecase | action-slack
title: Use case
metaTitle: Use case | action-slack
metaDescription: This describes the usecase of action-slack.
---
Usecase
This page introduces a use case using action-slack.
- [General use case](/usecase/01-general)
- [Custom use case](/usecase/02-custom)

Просмотреть файл

@ -1,7 +0,0 @@
---
title: Basic Usecase
metaTitle: Basic Usecase | action-slack
metaDescription: This describes the basic usecase of action-slack.
---
basic

Просмотреть файл

@ -0,0 +1,24 @@
---
title: General use case
metaTitle: General use case | action-slack
metaDescription: This describes the general use case of action-slack.
---
Notify slack of the results of a single job run.
```yaml
steps:
- uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took # selectable (default: repo,message)
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.
```
`status: ${{ job.status }}` allows a job to succeed, fail or cancel etc. to action-slack.
`if: always()` to trigger action-slack even if the job fails Let them.
For the fields, look at [Fields](/fields) to determine what you want.

Просмотреть файл

@ -0,0 +1,79 @@
---
title: Custom use case
metaTitle: Custom use case | action-slack
metaDescription: This describes the custom use case of action-slack.
---
You will often want to send notifications in a format other than the one that action-slack has determined.
In such a case, consider using `type: custom`.
If you specify a payload in accordance with the slack specification, action-slack will notify you as it is.
Use `status: cutom` and [custom_payload](/with#custom_payload) to customize notifications to your liking can be sent.
```yaml
steps:
- uses: 8398a7/action-slack@v3
with:
status: custom
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
```
As you can see, the JavaScript functionality is available in the custom_payload . (e.g. `toLowerCase()`)
We have even more options for those who want to use custom notifications, but want to use the Fields feature.
```yaml
steps:
- uses: 8398a7/action-slack@v3
with:
status: custom
fields: all
custom_payload: |
{
username: 'action-slack',
icon_emoji: ':octocat:',
attachments: [{
color: 'good',
text: `${process.env.AS_WORKFLOW}\n${process.env.AS_JOB} (${process.env.AS_COMMIT}) of ${process.env.AS_REPO}@master by ${process.env.AS_AUTHOR} succeeded in ${process.env.AS_TOOK}`,
}]
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_LEGACY_WEBHOOK_URL_FOR_INTEGRATION_TEST }}
```
You can access the values retrieved by Fields through environment variables.
See [Fields](/fields) for the available environment variables.
<img width="633" alt="custom" src="https://user-images.githubusercontent.com/8043276/85947865-3723b800-b988-11ea-80f7-6db5329c6af7.png" />
If there's a good format, I'd like to introduce it on this page from time to time.

Просмотреть файл

@ -8,19 +8,19 @@ This page describes the elements that can be specified in with.
# List
|key|value|default|
|---|---|---|
|[status](/with#status)|`'success'` or `'failure'` or `'cancelled'` or `'custom'`|`''`|
|[fields](/with#fields)|You can choose the items you want to add to the fields at the time of notification.|`'repo,commit'`|
|[text](/with#text)|Specify the text you want to add.|`''`|
|[author_name](/with#author_name)|It can be overwritten by specifying. The job name is recommend.|`'8398a7@action-slack'`|
|[mention](/with#mention)|`'here'` or `'channel'` or [user_group_id](https://api.slack.com/reference/surfaces/formatting#mentioning-groups) or [user_id](https://api.slack.com/reference/surfaces/formatting#mentioning-users)|`''`|
|[if_mention](/with#mention)|Specify `'success'` or `'failure'` or `'cancelled'` or `'custom'` or `'always'`.|`''`|
|[username](/with#username)|Override the legacy integration's default name.|`''`|
|[icon_emoji](/with#icon_emoji)|[emoji code](https://www.webfx.com/tools/emoji-cheat-sheet/) string to use in place of the default icon.|`''`|
|[icon_url](/with#icon_url)|icon image URL string to use in place of the default icon.|`''`|
|[channel](/with#channel)|Override the legacy integration's default channel. This should be an ID, such as `C8UJ12P4P`.|`''`|
|[custom_payload](/with#custom_payload)|e.g. `{"text": "Custom Field Check", obj: 'LOWER CASE'.toLowerCase()}`|`''`|
| key | value | default |
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- |
| [status](/with#status) | `'success'` or `'failure'` or `'cancelled'` or `'custom'` | `''` |
| [fields](/fields) | You can choose the items you want to add to the fields at the time of notification. | `'repo,commit'` |
| [text](/with#text) | Specify the text you want to add. | `''` |
| [author_name](/with#author_name) | It can be overwritten by specifying. The job name is recommend. | `'8398a7@action-slack'` |
| [mention](/with#mention) | `'here'` or `'channel'` or [user_group_id](https://api.slack.com/reference/surfaces/formatting#mentioning-groups) or [user_id](https://api.slack.com/reference/surfaces/formatting#mentioning-users) | `''` |
| [if_mention](/with#mention) | Specify `'success'` or `'failure'` or `'cancelled'` or `'custom'` or `'always'`. | `''` |
| [username](/with#username) | Override the legacy integration's default name. | `''` |
| [icon_emoji](/with#icon_emoji) | [emoji code](https://www.webfx.com/tools/emoji-cheat-sheet/) string to use in place of the default icon. | `''` |
| [icon_url](/with#icon_url) | icon image URL string to use in place of the default icon. | `''` |
| [channel](/with#channel) | Override the legacy integration's default channel. This should be an ID, such as `C8UJ12P4P`. | `''` |
| [custom_payload](/with#custom_payload) | e.g. `{"text": "Custom Field Check", obj: 'LOWER CASE'.toLowerCase()}` | `''` |
# status
@ -36,35 +36,6 @@ steps:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
```
# fields
If you have more than one, please enter it in csv format.
Corresponding types are as follows.
- repo
- commit
- message
- required GITHUB_TOKEN
- author
- required GITHUB_TOKEN
- job
- required GITHUB_TOKEN
- took
- required GITHUB_TOKEN
- eventName
- ref
- workflow
```yaml
steps:
- uses: 8398a7/action-slack@v3
with:
fields: repo,commit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
```
# text
e.g.