Skip to content

vaporif/slack-file-upload-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Slack file upload action

Integration Tests

This action uploads file(s) to slack using v2 files API.

Inputs

token

Required Slack app token. See Internal app tokens

  1. Create app
  2. Add files:write and files:read permission
  3. Install app to your workspase
  4. Invite bot to required channels /invite <botname>
  5. Use bot token from OAuth & Permissions page

files

Required List of files including file path and filename remember json wont work with backslashes so you might need ${{ toJSON(variable) }}

channel_id

THIS IS NOT A CHANNEL NAME Slack channel ID for upload

ID is included in the URL of a channel in web version.

thread_ts

Slack thread for upload

initial_comment

The message text introducing the file in specified channels.

Example usage

on: [push]

jobs:
  slack_upload_job:
    runs-on: ubuntu-latest
    name: Upload test file
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - run: |
          mkdir dir
          echo "Test file " > dir/test.txt
      - name: Upload to slack step
        uses: vaporif/slack-file-upload-action@v1
        with:
          token: ${{ secrets.SLACK_TOKEN }}
          files: >
            [
              {"file": "./dir/test.txt", "filename": "testfile.txt"},
              {"file": "./dir/test.txt", "filename": "testfile.txt"}
            ]
          channel_id: C06S5FLDSN4