Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iroachie/slack-github-actions
A no-config GitHub action that notifies slack of the status of your GitHub actions
https://github.com/iroachie/slack-github-actions
github-action hac hacktoberfest nodejs slack typescript
Last synced: 3 months ago
JSON representation
A no-config GitHub action that notifies slack of the status of your GitHub actions
- Host: GitHub
- URL: https://github.com/iroachie/slack-github-actions
- Owner: iRoachie
- License: mit
- Created: 2020-06-02T00:45:21.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-10-18T15:11:26.000Z (over 1 year ago)
- Last Synced: 2024-11-04T14:45:48.129Z (4 months ago)
- Topics: github-action, hac, hacktoberfest, nodejs, slack, typescript
- Language: TypeScript
- Homepage: https://github.com/marketplace/actions/slack-github-actions
- Size: 799 KB
- Stars: 11
- Watchers: 2
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Slack Github Actions
A no-config GitHub action that notifies slack of the status of your GitHub actions

## Supported Triggers
We currently support:
- `pull_request`
- `release`
- `push` (tags, commits)
- `schedule`
- `create (branch)`
- `delete (branch)`## Messages
All event messages will have these elements:

1. Build Indicator - Will be green for successful, red for failed, yellow for cancelled
2. Author Github Profile and User - This is also a link their profile page
3. Workflow Name - Also a link to the run
4. Repository Name - Also a link
5. Timestamp---
### Pull Requests

1. Commit Hash - Also a link showing the changes between the base and ref
2. Pull Request Number and Title - Also a link to the Pull Request---
### Releases

1. Commit Hash - Also a link showing all changes in the release
2. Release Title - Also a link to the release and notes. _If the release doesn't have a title the tag name will be used._---
### Tags

1. Commit Hash - Also a link showing all changes since this tag and master
2. Tag name - Also a link to the tag### Commits

1. Commit Hash - Also a link showing combined changes of all commits for the push
2. Head Commit name - Name of last commit in the batch (can push multiple commits). Also a link to that commit.### Schedule

> Note that Schedule does not have the user as there's no commit information.
### Create

1. Branch Name - Also link to the branch.
### Delete

1. Branch Name
## Usage
You can use this action after any other action, however I recommend you put it as the last one. Here is an example setup of this action for a pull request:
1. Create a `.github/workflows/test.yml` file in your GitHub repo.
2. Add the following code to the `test.yml` file.```yaml
name: Teston:
pull_request:
branches:
- masterjobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2- run: npm install
- run: npm test- uses: iRoachie/[email protected]
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
status: ${{ job.status }}
if: ${{ always() }}
```3. Create `SLACK_WEBHOOK_URL` secret using [GitHub Action's Secret](https://developer.github.com/actions/creating-workflows/storing-secrets). You can [generate a Slack incoming webhook token from here.](https://slack.com/apps/A0F7XDUAZ-incoming-webhooks)
## Advanced Usage
Here's an example with jobs that run in parallel.
It does a few things:
- Lets us know when a status check didn't succeed
- If all jobs were successful, we'll send a message at the end> Note that the status variable is omitted here.
```yaml
name: Teston:
pull_request:
branches:
- masterjobs:
test:
name: Jest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: yarn testlint:
name: Eslint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: yarn
- run: yarn lintnotify:
Name: Slack
needs: [test, lint] # We only check after the others jobs have run
if: always() # Always runs even if one of the builds fails
runs-on: ubuntu-latest
steps:
- uses: iRoachie/[email protected]
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```