This action is kfei/slack-cleaner for GitHub Actions.
Generated from actions/container-action template.
Here is an example workflow setting of this action.
-
Create a
.github/workflows/slack-cleaner.yml
file in your GitHub repository you want setup. -
Add the following code to the
slack-cleaner.yml
file.
# .github/workflows/slack-cleaner.yml
name: 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
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 |
Expand to see an example workflow
# .github/workflows/slack-cleaner.yml
name: 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
Expand to see an example workflow
# .github/workflows/slack-cleaner.yml
name: 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
Expand to see an example workflow
# .github/workflows/slack-cleaner.yml
name: 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
Expand to see an example workflow
# .github/workflows/slack-cleaner.yml
name: 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
Expand to see an example workflow
Note: that the list of usernames must contains yourself.
# .github/workflows/slack-cleaner.yml
name: 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
Expand to see an example workflow
# .github/workflows/slack-cleaner.yml
name: 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
Expand to see an example workflow
# .github/workflows/slack-cleaner.yml
name: 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
Expand to see an example workflow
# .github/workflows/slack-cleaner.yml
name: 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
Expand to see an example workflow
# .github/workflows/slack-cleaner.yml
name: 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
Expand to see an example workflow
# .github/workflows/slack-cleaner.yml
name: 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
Expand to see an example workflow
# .github/workflows/slack-cleaner.yml
name: 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
This project is licensed under the MIT License.