Skip to content

AiCure/slack-upload-file

 
 

Repository files navigation

slack-upload-file

CI-Master
upload file to slack action

Example

name: Slack

on:
  workflow_dispatch:
    inputs:
      message: 
        description: 'post message as text file to slack'
        required: true
        default: 'Hello World!'

jobs:
  post:
    runs-on: ubuntu-latest
    steps:
      - run: 'echo ${{ github.event.inputs.message }} > message.txt'
      - uses: MeilCli/slack-upload-file@v2
        with:
          slack_token: ${{ secrets.SLACK_TOKEN }}
          channels: ${{ secrets.SLACK_CHANNELS }}
          file_path: 'message.txt'
          file_type: 'text'
          initial_comment: 'post by slack-upload-file'

You can also pin to a specific release version in the format @v2.x.x

Information

  • This action execute simply files.upload, and can upload multiple files by glob pattern
  • How get slack token? see Basic app setup
  • How choose Oauth Scope? This action require only files:write. In simply case, you do choose files:write Bot Token Scope.

Input

  • slack_token
    • required
    • Slack token, must has files:write permission
  • slack_api_url
    • Custom slack api url
  • channels
    • Comma-separated list of channel names or IDs where the file will be shared.
  • content
    • File contents via a POST variable. If omitting this parameter, you must provide a file.
  • file_path
    • File contents via multipart/form-data. If omitting this parameter, you must submit content.
    • You can use glob pattern
  • file_path_follow_symbolic_links
    • Indicates whether to follow symbolic links
    • This parameter only use glob pattern
    • default: true
  • file_name
    • Filename of file.
    • This parameter can only use providing content
  • file_type
  • initial_comment
    • The message text introducing the file in specified channels.
  • thread_ts
    • Provide another message's ts value to upload this file as a reply. Never use a reply's ts value; use its parent instead.
  • title
    • Title of file.
  • retries
    • max API retry count. default retries is 3.

Output

  • response
    • the api response

Example

jobs:
  post:
    runs-on: ubuntu-latest
    steps:
      - run: 'echo ${{ github.event.inputs.message }} > message.txt'
      - uses: MeilCli/slack-upload-file@v2
        id: message
        with:
          slack_token: ${{ secrets.SLACK_TOKEN }}
          channels: ${{ secrets.SLACK_CHANNELS }}
          file_path: 'message.txt'
          file_type: 'text'
          initial_comment: 'post by slack-upload-file'
      - run: 'echo ${{ fromJson(steps.message.outputs.response).file.permalink }}'

Contributes

Could you want to contribute?

see Contributing.md

License

Using

Packages

No packages published

Languages

  • TypeScript 100.0%