Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
aabed committed Sep 19, 2024
0 parents commit 34bb605
Show file tree
Hide file tree
Showing 8 changed files with 41,487 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Test Slack Upload

on: [push]

jobs:
slack-upload:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- run: echo testing> ./foo.txt
- name: Upload file to Slack
uses: ./ # Use the current action for testing
with:
slack_token: ${{ secrets.SLACK_TOKEN }}
file_path: './foo.txt'
channel_id: 'C0755Q8AATT'
initial_comment: "**TEST**"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Slack File Upload Action

This GitHub Action allows you to upload files to a Slack channel using a Slack bot. It leverages the Slack Web API to handle file uploads and can be easily integrated into any GitHub Actions workflow.

## Features

- Upload files from your repository or workflow to a specified Slack channel.
- Use Slack bot tokens to authenticate the upload.
- Supports setting file titles and sharing file URLs in the Slack channel.

## Usage

### Basic Example

```yaml
name: Slack File Upload

on:
push:
branches:
- main

jobs:
upload-file:
runs-on: ubuntu-latest
steps:
- name: Checkout repository content
uses: actions/checkout@v3

- name: Upload file to Slack
uses: aabed/slack-file-upload-action@v1.0.0
with:
slack_token: ${{ secrets.SLACK_TOKEN }}
file_path: './file.txt'
channel_id: 'C0123456789'
initial_comment: 'Here is the file!'

```

### Inputs

| Input | Description | Required | Default |
|--------------|-------------------------------------------------|----------|---------|
| `slack_token`| The Slack bot token (`xoxb-...`). | `true` | |
| `file_path` | Path to the file you want to upload. | `true` | |
| `channel_id` | The ID of the Slack channel where the file is uploaded. | `true` | |
| `initial_comment` | An optional comment to include with the file upload. | `false` | |

### Outputs

| Output | Description |
|------------|-------------------------------------|
| `file_url` | The public URL of the uploaded file.|


### Setup Slack Bot Token

To use this action, you will need a Slack bot token:

1. Go to your [Slack API](https://api.slack.com/) dashboard.
2. Create a new Slack App and enable the `files:write` and `files:read` permissions.
3. Install the app to your workspace and generate the bot token (`xoxb-...`).
4. Add the token to your GitHub repository's secrets under `Settings > Secrets and variables > Actions` as `SLACK_TOKEN`.

28 changes: 28 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 'Upload File to Slack'
description: 'GitHub Action to upload files to a Slack channel using a custom Node.js script.'
author: 'Your Name'
branding:
icon: 'upload'
color: 'blue'

inputs:
slack_token:
description: 'The Slack bot token (xoxb-...)'
required: true
file_path:
description: 'The path to the file that should be uploaded.'
required: true
channel_id:
description: 'The Slack channel ID where the file should be uploaded.'
required: true
initial_comment:
description: 'An optional comment to include with the file upload.'
required: false

runs:
using: 'node16'
main: 'dist/index.js'

outputs:
file_url:
description: 'The URL of the uploaded file in Slack.'
Loading

0 comments on commit 34bb605

Please sign in to comment.