-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 34bb605
Showing
8 changed files
with
41,487 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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**" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.' |
Oops, something went wrong.