A CI pipeline
This GitHub Actions workflow runs on every push to main that touches templates/. It installs the CLI and plugin, logs in to prod, validates the files offline, previews the changes, then imports with --fail-on-warnings so any warning rolls the import back and fails the build.
validate and diff take one .sdt file at a time, so the workflow loops over every file in templates/. import takes the whole folder.
name: Promote templates to prod
on:
push:
branches: [main]
paths: ['templates/**']
jobs:
promote:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install sf CLI and plugin
run: |
npm install -g @salesforce/cli
sf plugins install @sliick/sfdx-plugin
- name: Authenticate
run: |
echo "${{ secrets.SFDX_AUTH_URL }}" | sf org login sfdx-url --sfdx-url-stdin --alias prod
- name: Validate artefacts
run: |
for f in templates/*.sdt; do sf sliick docs validate "$f"; done
- name: Preview changes
run: |
for f in templates/*.sdt; do sf sliick docs diff "$f" --target-org prod; done
- name: Import
run: sf sliick docs import templates/ --target-org prod --fail-on-warnings
To use JWT instead of sfdx-url, swap the Authenticate step:
- name: Authenticate (JWT)
run: |
echo "${{ secrets.JWT_KEY }}" > server.key
sf org login jwt \
--username ${{ secrets.SF_USERNAME }} \
--jwt-key-file server.key \
--client-id ${{ secrets.SF_CLIENT_ID }} \
--alias prod