npm package: @orange-soft/strapi-deployment-trigger
Description: Strapi v5 plugin to trigger GitHub Actions workflow deployments from the admin panel
Author: Justin Moh
Latest version: 1.2.0

# Strapi Plugin: Deployment Trigger

A Strapi v5 plugin that allows you to trigger deployments directly from the Strapi admin panel. Supports both **GitHub Actions** and **Vercel** deployments.

## Features

- Trigger **GitHub Actions** `workflow_dispatch` events from the admin UI
- Trigger **Vercel** deployments via deploy hooks
- Configure multiple deployment targets (e.g., Production, Staging)
- Support for different trigger types per target
- Secure token storage in database
- Token masking for security
- Direct link to GitHub Actions to monitor deployment progress

## Requirements

- Strapi v5.x
- Node.js >= 18.x
- A GitHub repository with a workflow that supports `workflow_dispatch`

## Installation

```bash
npm install @orange-soft/strapi-deployment-trigger
# or
yarn add @orange-soft/strapi-deployment-trigger
```

## Configuration

### 1. Enable the plugin

Add the plugin to your `config/plugins.ts` (or `config/plugins.js`):

```typescript
export default () => ({
  'deployment-trigger': {
    enabled: true,
  },
});
```

### 2. Configure via Admin UI

1. Go to **Plugins > Deployment Trigger > Settings** in your Strapi admin
2. **For GitHub targets:**
   - Enter your GitHub repository URL (e.g., `https://github.com/owner/repo`)
   - Enter your GitHub Personal Access Token
   - Add a target with type "GitHub", workflow filename, and branch
3. **For Vercel targets:**
   - Add a target with type "Vercel" and paste your deploy hook URL

All settings including tokens are stored securely in the Strapi database.

## GitHub Token Setup

You need a GitHub **Fine-grained Personal Access Token** with the following permissions:

1. Go to GitHub > Settings > Developer settings > Personal access tokens > Fine-grained tokens
2. Click "Generate new token"
3. Set token name and expiration
4. Select the target repository under "Repository access"
5. Under "Repository permissions", set **Actions** to "Read and write"
6. Click "Generate token"

## GitHub Workflow Setup

Your workflow file (e.g., `.github/workflows/deploy.yml`) must include the `workflow_dispatch` trigger:

```yaml
name: Deploy

on:
  workflow_dispatch:

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      # ... your deployment steps
```

## Vercel Deploy Hook Setup

To trigger Vercel deployments, you need to create a Deploy Hook:

1. Go to your Vercel project dashboard
2. Navigate to **Settings** > **Git**
3. Scroll down to **Deploy Hooks**
4. Click **Create Hook**
5. Enter a name (e.g., "Strapi Trigger") and select the branch
6. Click **Create Hook**
7. Copy the generated webhook URL (starts with `https://api.vercel.com/v1/integrations/deploy/...`)
8. Paste this URL when adding a Vercel target in the plugin settings

## Usage

1. Navigate to **Plugins > Deployment Trigger > Settings** in your Strapi admin
2. For GitHub targets: Configure repository URL and GitHub token
3. Add deployment targets:
   - **GitHub**: Select type "GitHub", enter name, workflow file, and branch
   - **Vercel**: Select type "Vercel", enter name and webhook URL
4. Go to the main **Deployment Trigger** page
5. Click **Trigger** on any configured target
6. For GitHub targets, click the provided link to monitor progress in GitHub Actions

## API

The plugin exposes the following admin API endpoints:

| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | `/deployment-trigger/settings` | Get current settings |
| PUT | `/deployment-trigger/settings` | Update settings |
| GET | `/deployment-trigger/status` | Get configuration status |
| POST | `/deployment-trigger/trigger` | Trigger deployment |

## License

MIT

## Author

Justin Moh <moh@os.my>

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.