# Reminix with GitHub

> Publish your scripts from GitHub Actions on every push to main, and start a script when a GitHub webhook calls.

Your scripts live in GitHub, and your team runs them on Reminix. With one workflow file, every change merged to `main` is the version your team runs. A GitHub webhook can also start a script the moment something happens in a repository.

## Publish on every push to main

It takes two steps: a token, and a workflow file.

### 1. Save a token in the repository

In Reminix, open **Account → Personal access tokens** and create a token:

* **Workspaces:** only the workspace the scripts belong to.
* **Access:** **Publish and run scripts**.

In GitHub, open the repository’s **Settings → Secrets and variables → Actions**. Add the token as a secret named `REMINIX_TOKEN`.

### 2. Add the workflow

Save this as `.github/workflows/publish-scripts.yml`, with your workspace’s slug. It publishes only the script folders a push changed:

```yaml
name: Publish scripts

on:
  push:
    branches: [main]
    paths: ["scripts/**"]

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
        with:
          fetch-depth: 0
      - uses: actions/setup-node@v7
        with:
          node-version: 24
      - name: Publish the changed scripts
        env:
          REMINIX_TOKEN: ${{ secrets.REMINIX_TOKEN }}
          REMINIX_WORKSPACE: acme-ops
        run: |
          folders=""
          for name in $(git diff --name-only ${{ github.event.before }} ${{ github.sha }} -- scripts | cut -d/ -f2 | sort -u); do
            if [ -d "scripts/$name" ]; then folders="$folders scripts/$name"; fi
          done
          if [ -n "$folders" ]; then npx --yes @reminix/cli publish $folders; fi
```

### What you see

Push a change to one script. The workflow’s run on GitHub prints each version it published, such as `Published monthly-report version 3`. In Reminix, the script’s page lists the new version under **Versions**, with who published it.

[Publish from GitHub](/docs/guides/publish-from-github/) covers approvals for new versions and uploading drafts instead.

## Start a script from a GitHub webhook

It takes three steps: a trigger, a webhook and a few lines in the script.

### 1. Add the trigger

Make up a long random secret for GitHub to sign its calls with:

```bash
openssl rand -hex 32
```

On the script’s page in Reminix, choose **Triggers → Add trigger**, then **When something calls its webhook URL**:

* **Inputs:** **The whole request**.
* **Signature:** **GitHub**, with the secret you made.

Reminix shows the trigger’s URL once. Copy it.

### 2. Add the webhook in GitHub

In the repository, open **Settings → Webhooks** and click **Add webhook**:

* **Payload URL:** the trigger’s URL.
* **Content type:** `application/json`.
* **Secret:** the same secret.
* **Events:** only the events the script needs, such as **Just the push event**.

Reminix checks the `X-Hub-Signature-256` header on every call and refuses one without GitHub’s valid signature.

### 3. Read the event in the script

The script declares one input, `request`, of type object. The event’s name is in its headers, and GitHub’s payload is its body:

```python
import json
import os

with open(os.environ["REMINIX_INPUTS_FILE"]) as f:
    request = json.load(f)["request"]

if request["headers"].get("x-github-event") == "push":
    print(json.dumps({"ref": request["body"]["ref"]}))
```

### What you see

GitHub sends a `ping` event as soon as you add the webhook. It starts a run, and this script skips it. After that, each push starts one run. The trigger’s **Recent calls** lists every call. If GitHub sends a delivery again, Reminix answers with the first run, by its `X-GitHub-Delivery` id.

[Schedules and triggers](/docs/schedules-and-triggers/#webhook-triggers) has every rule for webhook triggers.
