https://github.com/swfz/failed-log-to-slack-action
Custom action to notify Slack of the contents of the failure log or annotation when an Actions workflow fails.
https://github.com/swfz/failed-log-to-slack-action
github-actions notification slack
Last synced: 2 months ago
JSON representation
Custom action to notify Slack of the contents of the failure log or annotation when an Actions workflow fails.
- Host: GitHub
- URL: https://github.com/swfz/failed-log-to-slack-action
- Owner: swfz
- License: mit
- Created: 2023-12-26T10:46:15.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-08-28T23:01:44.000Z (10 months ago)
- Last Synced: 2025-08-29T04:22:53.024Z (10 months ago)
- Topics: github-actions, notification, slack
- Language: TypeScript
- Homepage:
- Size: 1.22 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# failed-log-to-slack-action
[](./badges/coverage.svg)
Custom action to notify Slack of the contents of the failure log or
annotation when an Actions workflow fails.
## Example

- `See more` clicked

## Usage
### call by workflow_run trigger
- .github/workflows/slack.yml
```yaml
name: slack notification
on:
workflow_run:
workflows:
- ci
- analysis
types:
- completed
jobs:
main:
name: main
runs-on: ubuntu-latest
steps:
- uses: swfz/failed-log-to-slack-action@v1.1.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
```
`ci`,`analysis` is other workflow name
run this workflow is there workflow completed
[deprecated] call by workflow configuration
- .github/workflows/xxxxx.yml
```yaml
name: ci
on: [push]
jobs:
test:
.....
.....
slack-notify:
if: always()
needs: [test]
name: post slack
runs-on: ubuntu-latest
steps:
- uses: swfz/failed-log-to-slack-action@v1.1.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
```
If this Action is called in the same workflow configuration while the log file is being acquired,
the log file generation does not finish because the workflow is still running.
Therefore, the information obtained is less than that of the notification processed via `workflow_run`
because the information in the log file cannot be obtained.
## Development
Enter the actual values you want to use.
```shell
export INPUT_GITHUB_TOKEN=xxxxx
export SLACK_WEBHOOK_URL=xxxxx
source script/dev_env.sh https://github.com/{owner}/{repo}/actions/runs/{run_id}
```
required `gh` command
Pass the URL of the GitHub Workflow execution result to the script
and set the environment variables necessary for development.
### simple execution
```shell
ts-node src/index.ts
```