Markdown Viewer

GitHub Actions Setup for SMT Studio Migration

This guide walks through every prerequisite and configuration step required to run the generated smt-studio GitHub Actions workflow.


Overview

The workflow:

  1. Checks out your repository (which contains the load plan)
  2. Installs Node.js and smt-studio
  3. Authenticates both Salesforce orgs using JWT (non-interactive, CI-safe)
  4. Runs smt-studio cli to perform the migration or CSV generation

Prerequisites

1. Salesforce External Client App (JWT Auth)

GitHub Actions authenticates to Salesforce using JWT Bearer Flow — no browser, no interactive login. Salesforce recommends using an External Client App (the successor to Connected Apps) for new integrations.

Steps (repeat for each org):

  1. In Salesforce Setup, search for External Client Apps → New External Client App

    Legacy path: App Manager → New Connected App still works but is no longer recommended.

  2. Fill in the app name and contact email
  3. Under OAuth Settings, enable Enable OAuth
  4. Set Callback URL to https://login.salesforce.com/services/oauth2/callback (placeholder — not used by JWT flow)
  5. Enable Use Digital Signatures, upload your certificate (.crt file)
  6. Add OAuth scopes: Manage user data via APIs (api), Perform requests at any time (refresh_token, offline_access)
  7. Save and note the Consumer Key — this becomes SF_CLIENT_ID
  8. Click Manage → Edit Policies → set Permitted Users to Admin approved users are pre-authorized
  9. Assign the app to the migration user's Profile or Permission Set

If both orgs share the same certificate, one External Client App / SF_CLIENT_ID can cover both.

2. Generate a Certificate and Private Key

# Generate a private key and self-signed certificate (valid 10 years)
openssl genrsa -out server.key 2048
openssl req -new -x509 -key server.key -out server.crt -days 3650 \
  -subj "/CN=smt-studio-ci"

3. Generate an SMT_SECRET

SMT_SECRET is a Bearer token that guards the smt-studio REST API. Generate a random value:

# macOS / Linux
openssl rand -hex 32

# PowerShell (Windows)
[System.Convert]::ToHexString([System.Security.Cryptography.RandomNumberGenerator]::GetBytes(32)).ToLower()

Store the output as the SMT_SECRET GitHub secret.


GitHub Repository Setup

4. Add Repository Secrets

Go to Settings → Secrets and variables → Actions → New repository secret and add:

Secret name Value
SF_CLIENT_ID Consumer Key from the Connected App
SF_JWT_KEY Full contents of server.key (including -----BEGIN RSA PRIVATE KEY----- lines)
SMT_SECRET Random hex string generated above

Never log or print these values in workflow steps.

5. Commit the Load Plan to the Repository

The CI runner has no access to your local filesystem. The load plan must be committed to the repo.

Recommended structure:

your-repo/
  load-plans/
    load-plan-vehicle.json   ← committed here
  .github/
    workflows/
      smt-migration.yml
mkdir -p load-plans
cp ~/Documents/load-plan-vehicle.json load-plans/
git add load-plans/load-plan-vehicle.json
git commit -m "add load plan for Vehicle migration"
git push

6. Add the Workflow File

Create .github/workflows/smt-migration.yml with the generated content from SMT Studio's GitHub CI tab:

name: SMT Studio Migration

on:
  push:
    branches: [main]
  workflow_dispatch:

jobs:
  migrate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        # The load plan must be committed to the repo under load-plans/

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '18'

      - name: Install smt-studio
        run: npm install -g smt-studio

      - name: Authenticate source org
        run: |
          echo "${{ secrets.SF_JWT_KEY }}" > /tmp/server.key
          sf org login jwt \
            --client-id ${{ secrets.SF_CLIENT_ID }} \
            --jwt-key-file /tmp/server.key \
            --username mchinnappan@salesforce.com.af102 --alias source-org

      - name: Authenticate target org
        run: |
          sf org login jwt \
            --client-id ${{ secrets.SF_CLIENT_ID }} \
            --jwt-key-file /tmp/server.key \
            --username mohan.chinnappan.n5.b3a2393cf971@agentforce.com --alias target-org

      - name: Run migration
        env:
          SMT_SECRET: ${{ secrets.SMT_SECRET }}
        run: |
          # NOTE: load-plans/load-plan-vehicle.json must be committed to this repository under load-plans/
          smt-studio cli \
            -s mchinnappan@salesforce.com.af102 \
            -t mohan.chinnappan.n5.b3a2393cf971@agentforce.com \
            -l load-plans/load-plan-vehicle.json \
            -o migrate \
            --object Vehicle__c \
            --headless

Copy this directly from the 🐙 GitHub tab in SMT Studio's Migration screen — it is pre-filled with your connected orgs, load plan path, and selected objects.


Running the Workflow

Trigger on push

Any push to main triggers the workflow automatically (as configured in on: push: branches: [main]).

Trigger manually

  1. Go to Actions tab in your GitHub repository
  2. Select SMT Studio Migration from the left sidebar
  3. Click Run workflow → choose branch → Run workflow

Dry Run First (Recommended)

Before running a full migration, change -o migrate to -o gen-csv-file to generate CSVs without loading data to the target org:

- name: Run migration
  run: |
    smt-studio cli \
      ...
      -o gen-csv-file \
      --headless

Add an artifact upload step to inspect the generated CSVs:

      - name: Upload CSVs
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: migration-csvs
          path: smt-output/*.csv

Only promote to -o migrate after reviewing the CSV output.


Troubleshooting

INVALID_LOGIN / JWT authentication fails

Cannot find module 'smt-studio'

ENOENT: load-plans/load-plan-vehicle.json

401 Unauthorized on API calls

Workflow runs but no data migrates


Security Checklist