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:
- Checks out your repository (which contains the load plan)
- Installs Node.js and
smt-studio - Authenticates both Salesforce orgs using JWT (non-interactive, CI-safe)
- Runs
smt-studio clito 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):
- 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.
- Fill in the app name and contact email
- Under OAuth Settings, enable Enable OAuth
- Set Callback URL to
https://login.salesforce.com/services/oauth2/callback(placeholder — not used by JWT flow) - Enable Use Digital Signatures, upload your certificate (
.crtfile) - Add OAuth scopes:
Manage user data via APIs (api),Perform requests at any time (refresh_token, offline_access) - Save and note the Consumer Key — this becomes
SF_CLIENT_ID - Click Manage → Edit Policies → set Permitted Users to
Admin approved users are pre-authorized - 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_IDcan 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"
- Upload
server.crtto the Connected App (step 4 above) - Store the contents of
server.keyas a GitHub secret (SF_JWT_KEY) — never commit the key file
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
- Go to Actions tab in your GitHub repository
- Select SMT Studio Migration from the left sidebar
- 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
- Verify the Connected App has Use Digital Signatures enabled and the correct
.crtuploaded - Confirm the user is pre-authorized via Profile or Permission Set on the Connected App
- Check
SF_CLIENT_IDmatches the Connected App's Consumer Key exactly
Cannot find module 'smt-studio'
- The
npm install -g smt-studiostep failed — check the Actions log for npm errors - Ensure the runner has internet access and npmjs.com is reachable
ENOENT: load-plans/load-plan-vehicle.json
- The load plan file is not committed to the repository
- Run the commit steps in section 5 above
401 Unauthorized on API calls
SMT_SECRETis set in the workflowenv:block but does not match what the server expects- For
climode the secret is used internally — ensure the secret value has no leading/trailing whitespace
Workflow runs but no data migrates
- Check the Actions log for
smt-studio clioutput — look for✅/❌lines - Try
-o gen-csv-filefirst to confirm records are being queried correctly
Security Checklist
-
server.keyis never committed to the repository — store only in GitHub Secrets -
SF_CLIENT_ID,SF_JWT_KEY,SMT_SECRETare all stored as encrypted repository secrets - The Connected App's Permitted Users is set to
Admin approved users are pre-authorized - Run
gen-csv-filebeforemigrateon first use in any new environment - Rotate
SMT_SECRETand the JWT key/certificate on a regular schedule