MeilCli / slack-upload-file

upload file to slack action

Home Page:https://github.com/MeilCli/actions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

slack-upload-file

CI-Master
upload file to slack action

Example

Post by files

jobs:
  post:
    runs-on: ubuntu-latest
    steps:
      - uses: MeilCli/slack-upload-file@v4
        with:
          slack_token: ${{ secrets.SLACK_TOKEN }}
          channel_id: ${{ secrets.SLACK_CHANNEL_ID }}
          file_path: 'docs/*.txt'
          initial_comment: 'post by slack-upload-file'
          # thread_ts: 'option'

Post by workflow yaml

jobs:
  post:
    runs-on: ubuntu-latest
    steps:
      - uses: MeilCli/slack-upload-file@v4
        with:
          slack_token: ${{ secrets.SLACK_TOKEN }}
          channel_id: ${{ secrets.SLACK_CHANNEL_ID }}
          content: 'file content'
          file_type: 'text'
          file_name: 'text.txt'
          title: 'title of file'
          initial_comment: 'post by slack-upload-file'
          # thread_ts: 'option'

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 files:read and files:write. In simply case, you do choose files:read and files:write Bot Token Scope.
  • Why use files:read Oauth scope? Because this action use files.uploadv2, and its api requires files:read.
  • You can also pin to a specific release version in the format @v4.x.x

Input

  • slack_token
    • required
    • Slack token, must has files:write permission
  • slack_api_url
    • Custom slack api url
  • channel_id
    • Slack channel id
  • 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
  • if_no_files_found
    • file not founding options: warn, error or ignore. alike actions/upload-artifact
    • warn: output warning, but do not fail
    • ignore: no output and do not fail
    • error: output warning and do fail
    • default: error
  • 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.
    • links might not work because files.uploadv2 limitation. ref: #695
  • 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.
  • delete_file_ids_before_upload
    • file deletion before upload. comma separeted file ids. this argument is purpose for previous uploaded file replacement.

Output

  • response
  • uploaded_file_ids
    • comma separeted uploaded file ids

Example

jobs:
  post:
    runs-on: ubuntu-latest
    steps:
      - run: 'echo ${{ github.event.inputs.message }} > message.txt'
      - uses: MeilCli/slack-upload-file@v4
        id: message
        with:
          slack_token: ${{ secrets.SLACK_TOKEN }}
          channel_id: ${{ secrets.SLACK_CHANNEL_ID }}
          file_path: 'message.txt'
          initial_comment: 'post by slack-upload-file'
      - run: 'echo ${{ fromJson(steps.message.outputs.response).files[0].file.permalink }}'

Migration from v2 to v3/v4

  • Must: add files:read permission scope to Slack App.
  • Need: change to channel_id from channels. channels is removed because it is deprecated.
  • Some: change some input and output.
    • input:
      • new: delete_file_id_before_upload, old: delete_file_id_before_upload
      • title is changed, it will not send when upload by files.
    • output:
      • new: uploaded_file_ids, old: uploaded_file_id
      • response is changed.

Contributes

Could you want to contribute?

see Contributing.md

License

Using

About

upload file to slack action

https://github.com/MeilCli/actions

License:MIT License


Languages

Language:TypeScript 100.0%