Skip to content

CLI Automation

The CLI is designed for headless use in CI, cron, and deployment jobs. Use an API token created in OpenPost and pass it through environment variables or stdin.

Environment

VariablePurpose
OPENPOST_TOKENBearer token for non-interactive API access.
OPENPOST_INSTANCEDefault OpenPost instance URL.
OPENPOST_WORKSPACEDefault workspace ID or name.
OPENPOST_OUTPUT=jsonDefault output format for scripts.
OPENPOST_PROFILESelects a named CLI profile.

Useful flags:

FlagPurpose
--yesSkip confirmation prompts.
--jsonPrint machine-readable JSON for one command.
--set <name-or-id>Publish through a managed social set instead of spelling out --accounts.
--schedule next-slotUse the next available posting schedule slot instead of posting immediately or choosing a fixed time.

For recurring jobs, prefer a workspace default social set and --schedule next-slot. After creating a default set with openpost set create <name> --accounts ... --default, automation can omit both --accounts and --set; the CLI resolves the default set at runtime.

GitHub Actions Example

yaml
name: Daily Build Summary

on:
  schedule:
    - cron: "0 17 * * 1-5"

jobs:
  post-summary:
    runs-on: ubuntu-latest
    env:
      OPENPOST_INSTANCE: ${{ secrets.OPENPOST_INSTANCE }}
      OPENPOST_TOKEN: ${{ secrets.OPENPOST_TOKEN }}
      OPENPOST_WORKSPACE: ${{ secrets.OPENPOST_WORKSPACE }}
      OPENPOST_OUTPUT: json
    steps:
      - name: Install OpenPost CLI
        run: curl -fsSL https://raw.githubusercontent.com/rodrgds/openpost/main/scripts/install-cli.sh | sh

      - name: Post summary
        run: |
          openpost post create \
            --content "Daily build completed for ${GITHUB_REPOSITORY}@${GITHUB_SHA}" \
            --schedule next-slot \
            --yes \
            --json

The complete command and flag reference is generated from the Cobra command tree at CLI Reference.

Released under the MIT License.