# Publish from GitHub

> Publish a new version of a script each time it changes on main, with a short GitHub Actions workflow.

Say your scripts live in a GitHub repository, one folder each. You want the version your team runs to be the one on `main`, without anyone publishing by hand.

## 1. Create a token for the workflow

In the app, open **Account → Personal access tokens** and create a personal access token for this repository:

* **Workspaces:** only the workspace the scripts belong to.
* **Access:** **Publish and run scripts**. Publishing reads the script before it uploads a version, so it needs `scripts:read` and `scripts:write`, and this choice grants both.
* **Expires:** after a year, and put a reminder in your calendar.

Publishing uses a person’s token on purpose, because each version records who published it. If your workspace asks a second person to approve new versions, the workflow’s run prints the approval link and the version waits for them.

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

## 2. Add the workflow

Save this as `.github/workflows/publish-scripts.yml`, and put in 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
```

Each script is one folder under `scripts/`, such as `scripts/monthly-report/`. Reminix works out how it runs, or reads its `reminix.json` if it has one (see [Scripts](/docs/scripts/)). The CLI reads the token from `REMINIX_TOKEN` and the workspace from `REMINIX_WORKSPACE`, so the workflow never logs in or writes the token to disk. It passes every changed folder to one `publish` command, which publishes each script. If any of them fails, the run fails. The workflow skips a folder that’s gone from `scripts/`, so archive that folder’s script in the app.

To publish every script in the folder at once, for example the first time, run `reminix publish scripts/` from your own computer.

To review a version before runs use it, run `upload` instead of `publish`. The CLI then uploads a draft for someone to test and publish in the app.

## 3. Check it

Push a change to one script and open the workflow’s run on GitHub. The run prints each version it published, such as `Published monthly-report version 3: https://app.reminix.com/scripts/monthly-report`. In Reminix, the script’s page lists the new version under **Versions**. It shows who published the version and when.

## What the file doesn’t cover

`reminix.json` holds what the code needs: its command, inputs, hosts, secrets and `timeoutSeconds`. Who may run a script, its schedules and triggers, and which runs need approval are settings in the app or the API. A push never changes them.
