Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ken-matsui/slack-cleaner
slack-cleaner for GitHub Actions
https://github.com/ken-matsui/slack-cleaner
github-actions slack
Last synced: 23 days ago
JSON representation
slack-cleaner for GitHub Actions
- Host: GitHub
- URL: https://github.com/ken-matsui/slack-cleaner
- Owner: ken-matsui
- License: mit
- Created: 2019-12-09T17:38:09.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-09-04T02:52:21.000Z (about 3 years ago)
- Last Synced: 2024-05-02T04:41:19.495Z (6 months ago)
- Topics: github-actions, slack
- Language: Shell
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# slack-cleaner
This action is [kfei/slack-cleaner](https://github.com/kfei/slack-cleaner) for GitHub Actions.
Generated from [actions/container-action](https://github.com/actions/container-action) template.
## Usage
Here is an example workflow setting of this action.
1. Create a `.github/workflows/slack-cleaner.yml` file in your GitHub repository you want setup.
2. Add the following code to the `slack-cleaner.yml` file.
```yml
# .github/workflows/slack-cleaner.ymlname: Slack Cleaner
on:
schedule:
- cron: '0 0 1 * *'
jobs:
clean:
runs-on: ubuntu-latest
steps:
- uses: ken-matsui/slack-cleaner@v1
with:
token: ${{ secrets.SLACK_LEGACY_TOKEN }}
message: true
channel: 'general'
user: '*'
before: '20191201'
perform: true
```## Input parameters
The only required parameter is `token`.
It should be a Slack legacy token, and you can get it from https://api.slack.com/custom-integrations/legacy-tokens.It should start with `xoxp`, not like bot token with `xoxb`.
And you need to set it to your GitHub repository secrets.
Please refer https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets to know how to do that and for more details.
| Parameter Name | Required | Default | Description |
|:--------------:|:---------:|:--------:|:------------|
| token | ○ | N/A | Slack API legacy token |
| rate | × | N/A | Delay between API calls (in seconds) |
| message | × | false | Delete messages |
| file | × | false | Delete files |
| channel | × | N/A | Channel name's, e.g., general |
| direct | × | N/A | Direct message's name, e.g., sherry |
| group | × | N/A | Private group's name |
| mpdirect | × | N/A | Multiparty direct message's name, e.g., sherry,james,johndoe |
| user | × | N/A | Delete messages/files from certain user |
| bot | × | false | Delete messages from bots |
| after | × | N/A | Delete messages/files newer than this time (YYYYMMDD) |
| before | × | N/A | Delete messages/files older than this time (YYYYMMDD) |
| types | × | N/A | Delete files of a certain type, e.g., posts,pdfs |
| perform | × | false | Perform the task |## Examples
### Progammatic Parameter
Expand to see an example workflow
```yml
# .github/workflows/slack-cleaner.ymlname: Slack Cleaner
on:
schedule:
- cron: '0 0 1 * *'
jobs:
clean:
runs-on: ubuntu-latest
steps:
- name: Get datetime
id: datetime
run: echo "::set-output name=value::$(date -d '-5 days' '+%Y%m%d')"
- uses: ken-matsui/slack-cleaner@v1
with:
token: ${{ secrets.SLACK_LEGACY_TOKEN }}
rate: '1'
message: true
channel: 'notifications'
user: '*'
before: ${{ steps.datetime.outputs.value }}
perform: true
```### Delete all messages from a channel
Expand to see an example workflow
```yml
# .github/workflows/slack-cleaner.ymlname: Slack Cleaner
on: push
jobs:
clean:
runs-on: ubuntu-latest
steps:
- uses: ken-matsui/slack-cleaner@v1
with:
token: ${{ secrets.SLACK_LEGACY_TOKEN }}
message: true
channel: 'general'
user: '*'
perform: true
```### Delete all messages from a private group
Expand to see an example workflow
```yml
# .github/workflows/slack-cleaner.ymlname: Slack Cleaner
on: push
jobs:
clean:
runs-on: ubuntu-latest
steps:
- uses: ken-matsui/slack-cleaner@v1
with:
token: ${{ secrets.SLACK_LEGACY_TOKEN }}
message: true
group: 'hr'
user: '*'
perform: true
```### Delete all messages from a direct message channel
Expand to see an example workflow
```yml
# .github/workflows/slack-cleaner.ymlname: Slack Cleaner
on: push
jobs:
clean:
runs-on: ubuntu-latest
steps:
- uses: ken-matsui/slack-cleaner@v1
with:
token: ${{ secrets.SLACK_LEGACY_TOKEN }}
message: true
direct: 'sherry'
user: 'johndoe'
perform: true
```### Delete all messages from a multiparty direct message channel
Expand to see an example workflow
**Note: that the list of usernames must contains yourself.**
```yml
# .github/workflows/slack-cleaner.ymlname: Slack Cleaner
on: push
jobs:
clean:
runs-on: ubuntu-latest
steps:
- uses: ken-matsui/slack-cleaner@v1
with:
token: ${{ secrets.SLACK_LEGACY_TOKEN }}
message: true
mpdirect: 'sherry,james,johndoe'
user: '*'
perform: true
```### Delete all messages from certain user
Expand to see an example workflow
```yml
# .github/workflows/slack-cleaner.ymlname: Slack Cleaner
on: push
jobs:
clean:
runs-on: ubuntu-latest
steps:
- uses: ken-matsui/slack-cleaner@v1
with:
token: ${{ secrets.SLACK_LEGACY_TOKEN }}
message: true
channel: 'gossip'
user: 'johndoe'
perform: true
```### Delete all messages from bots (especially flooding CI updates)
Expand to see an example workflow
```yml
# .github/workflows/slack-cleaner.ymlname: Slack Cleaner
on: push
jobs:
clean:
runs-on: ubuntu-latest
steps:
- uses: ken-matsui/slack-cleaner@v1
with:
token: ${{ secrets.SLACK_LEGACY_TOKEN }}
message: true
channel: 'auto-build'
bot: true
perform: true
```### Delete all messages older than 2015/09/19
Expand to see an example workflow
```yml
# .github/workflows/slack-cleaner.ymlname: Slack Cleaner
on: push
jobs:
clean:
runs-on: ubuntu-latest
steps:
- uses: ken-matsui/slack-cleaner@v1
with:
token: ${{ secrets.SLACK_LEGACY_TOKEN }}
message: true
channel: 'general'
user: '*'
before: '20150919'
perform: true
```### Delete all files
Expand to see an example workflow
```yml
# .github/workflows/slack-cleaner.ymlname: Slack Cleaner
on: push
jobs:
clean:
runs-on: ubuntu-latest
steps:
- uses: ken-matsui/slack-cleaner@v1
with:
token: ${{ secrets.SLACK_LEGACY_TOKEN }}
file: true
user: '*'
perform: true
```### Delete all files from certain user
Expand to see an example workflow
```yml
# .github/workflows/slack-cleaner.ymlname: Slack Cleaner
on: push
jobs:
clean:
runs-on: ubuntu-latest
steps:
- uses: ken-matsui/slack-cleaner@v1
with:
token: ${{ secrets.SLACK_LEGACY_TOKEN }}
file: true
user: 'johndoe'
perform: true
```### Delete all snippets and images
Expand to see an example workflow
```yml
# .github/workflows/slack-cleaner.ymlname: Slack Cleaner
on: push
jobs:
clean:
runs-on: ubuntu-latest
steps:
- uses: ken-matsui/slack-cleaner@v1
with:
token: ${{ secrets.SLACK_LEGACY_TOKEN }}
file: true
types: 'snippets,images'
perform: true
```## LICENSE
This project is licensed under the [MIT License](LICENSE).