Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
181 changes: 71 additions & 110 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,135 +1,96 @@
# Basis Theory GitHub Actions
# Basis Theory Public GitHub Actions

## Deploy Notifier
A collection of reusable GitHub Actions maintained by [Basis Theory](https://basistheory.com) for deployment notifications, Slack messaging, CI cache management, and runner utilities.

This action will notify a Slack channel on specific deployment actions.
## Available Actions

### Inputs
| Action | Description | Docs |
|---|---|---|
| [deploy-slack-action](./deploy-slack-action) | High-level composite for deploy lifecycle notifications | [docs](./docs/deploy-slack-action/index.md) |
| [draft-release-slack-action](./draft-release-slack-action) | Notify Slack when a draft release is created | [docs](./docs/draft-release-slack-action/index.md) |
| [helper-slack-action](./helper-slack-action) | Core Node.js engine for all deploy/release Slack notifications | [docs](./docs/helper-slack-action/index.md) |
| [public-ip](./public-ip) | Get the GitHub Actions runner's public IPv4 address | [docs](./docs/public-ip/index.md) |
| [slack-javascript-action](./slack-javascript-action) | Shared JS library used by the Slack actions (not consumed directly) | [docs](./docs/slack-javascript-action/index.md) |
| [slack-message-action](./slack-message-action) | General-purpose send, update, and thread Slack messages | [docs](./docs/slack-message-action/index.md) |

- `slack-api-token` - **Required** The Slack API token.
- `channel` - **Required** The channel to send the message.
- `mention_person` - **Optional** The user to mention in the message.
- `status` - **Optional** The status of the run. Can be `start`, `done`, or
`request`. Default is `start`.
See the [`docs/`](./docs) directory for detailed documentation, inputs/outputs, and usage examples for each action.

### Example usage
## Quick Start

### Deploy Notifications

```yaml
name: Product Deploy

on:
release:
branches: [ master ]
types: [ released ]
branches: [master]
types: [released]

jobs:
request_approval:
deploy:
runs-on: ubuntu-latest
steps:
- name: Send Deploy Request
uses: Basis-Theory/github-actions/deploy-slack-action@master
with:
slack-api-token: ${{ secrets.API_TOKEN }}
channel: ${{ vars.APPROVALS_CHANNEL }}
mention-person: ${{ vars.APPROVER }}
status: 'request'
- name: Start Deploy Message
uses: Basis-Theory/github-actions/deploy-slack-action@master
with:
slack-api-token: ${{ secrets.API_TOKEN }}
channel: ${{ vars.DEPLOY_CHANNEL }}
- name: Sleep for 10 seconds
run: sleep 10s
shell: bash
- name: Stop Deploy Message
if: always()
uses: Basis-Theory/github-actions/deploy-slack-action@master
with:
slack-api-token: ${{ secrets.API_TOKEN }}
channel: ${{ vars.DEPLOY_CHANNEL }}
status: 'done'
- name: Notify deploy start
uses: Basis-Theory/public-github-actions/deploy-slack-action@master
with:
slack-api-token: ${{ secrets.SLACK_API_TOKEN }}
channel: ${{ vars.DEPLOY_CHANNEL }}

# ... deploy steps ...

- name: Notify deploy done
if: always()
uses: Basis-Theory/public-github-actions/deploy-slack-action@master
with:
slack-api-token: ${{ secrets.SLACK_API_TOKEN }}
channel: ${{ vars.DEPLOY_CHANNEL }}
status: done
```

## Slack

This action sends a message to a Slack channel.
### Slack Messaging

### Inputs
```yaml
- name: Send a message
id: slack
uses: Basis-Theory/public-github-actions/slack-message-action@master
with:
slack-api-token: ${{ secrets.SLACK_API_TOKEN }}
channel: ${{ vars.CHANNEL }}
text: "Build started for ${{ github.repository }}"

- name: Update the message
uses: Basis-Theory/public-github-actions/slack-message-action@master
with:
slack-api-token: ${{ secrets.SLACK_API_TOKEN }}
channel: ${{ vars.CHANNEL }}
update-message-id: ${{ steps.slack.outputs.message_id }}
text: "Build finished: ${{ job.status }}"
```

- `slack-api-token` - **Required** The Slack API token.
- `channel` - **Required** The channel to send the message.
- `text` - **Optional** The text of the message.
- `blocks` - **Optional** The [blocks](https://app.slack.com/block-kit-builder/)
of the message.
- `update-message-id` - **Optional** The message ID to update.
- `thread-message-id` - **Optional** The message ID to add the message to a
thread.
### Public IP

### Outputs
```yaml
- name: Get runner IP
id: runner-ip
uses: Basis-Theory/public-github-actions/public-ip@master

- `message_id` - The message Id of the sent message
- run: echo "${{ steps.runner-ip.outputs.ipv4 }}"
```

### Example
## Repository Structure

```yaml
name: Send Messages
```
.
├── deploy-slack-action/ # Deploy notification composite action
├── draft-release-slack-action/ # Draft release notification composite action
├── helper-slack-action/ # Core Slack notification action (Node.js)
├── public-ip/ # Runner public IP composite action
├── slack-javascript-action/ # Shared JS source & build output
├── slack-message-action/ # General-purpose Slack messaging action
└── docs/ # Detailed documentation for each action
```

on:
push:
branches: [ master ]
## License

jobs:
request_approval:
runs-on: ubuntu-latest
steps:
- name: Just a message
id: first_message
uses: Basis-Theory/github-actions/slack-message-action@master
with:
slack-api-token: ${{ secrets.API_TOKEN }}
channel: ${{ vars.CHANNEL }}
blocks: |
[
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":rocket: Check it out"
}
}
]
- name: Update a message
id: update_message
uses: Basis-Theory/github-actions/slack-message-action@master
with:
slack-api-token: ${{ secrets.API_TOKEN }}
channel: ${{ vars.CHANNEL }}
update-message-id: ${{ steps.first_message.outputs.message_id }}
blocks: |
[
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":rocket: Check it out - updated"
}
}
]
- name: Thread a message
id: thread_message
uses: Basis-Theory/github-actions/slack-message-action@master
with:
slack-api-token: ${{ secrets.API_TOKEN }}
channel: ${{ vars.CHANNEL }}
thread-message-id: ${{ steps.first_message.outputs.message_id }}
blocks: |
[
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":threads: thead it out"
}
}
]
```
See [LICENSE](./LICENSE) for details.
48 changes: 0 additions & 48 deletions cache-cleanup/action.yml

This file was deleted.

61 changes: 61 additions & 0 deletions docs/deploy-slack-action/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# deploy-slack-action

A composite action that sends deployment lifecycle notifications to Slack. It wraps `helper-slack-action` and supports statuses: `start`, `done`, `request`, `success`, `cancelled`, `failure`.

## How it works

1. Resolves the job status from the `job-status` input or falls back to `job.status`
2. Delegates to `helper-slack-action` with the full GitHub context, Slack token, channel, and status

## Inputs

| Input | Required | Default | Description |
|---|---|---|---|
| `slack-api-token` | Yes | | Slack Bot API token |
| `channel` | Yes | | Slack channel ID to send the message to |
| `mention-person` | No | | Slack user to mention in the notification |
| `status` | No | `start` | Deploy status: `start`, `done`, `request`, `success`, `cancelled`, `failure` |
| `job-status` | No | | Overrides `job.status` for the final notification |

## Usage

### Basic deploy lifecycle

```yaml
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Notify deploy start
uses: Basis-Theory/public-github-actions/deploy-slack-action@master
with:
slack-api-token: ${{ secrets.SLACK_API_TOKEN }}
channel: C01234ABCDE
status: start

# ... deploy steps ...

- name: Notify deploy done
if: always()
uses: Basis-Theory/public-github-actions/deploy-slack-action@master
with:
slack-api-token: ${{ secrets.SLACK_API_TOKEN }}
channel: C01234ABCDE
status: done
```

### With approval request and mention

```yaml
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Request approval
uses: Basis-Theory/public-github-actions/deploy-slack-action@master
with:
slack-api-token: ${{ secrets.SLACK_API_TOKEN }}
channel: C01234ABCDE
status: request
mention-person: "@U01PT4W3RM5"
```
36 changes: 36 additions & 0 deletions docs/draft-release-slack-action/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# draft-release-slack-action

Sends a Slack notification when a draft release is created. It posts a message with the package name, version, contributing authors (mapped from GitHub usernames to Slack IDs), and a button linking to the release edit page.

## How it works

1. Captures the current job status
2. Delegates to `helper-slack-action` with `type: "draft-release-ready"`
3. The notification includes collaborator mentions resolved from the release notes' `@username` references

## Inputs

| Input | Required | Description |
|---|---|---|
| `slack-api-token` | Yes | Slack Bot API token |
| `channel` | Yes | Slack channel ID to send the message to |
| `mention-person` | No | Slack user to mention in the notification |

## Usage

```yaml
name: Draft Release Notification
on:
release:
types: [created]

jobs:
notify:
if: github.event.release.draft
runs-on: ubuntu-latest
steps:
- uses: Basis-Theory/public-github-actions/draft-release-slack-action@master
with:
slack-api-token: ${{ secrets.SLACK_API_TOKEN }}
channel: C01234ABCDE
```
Loading