Skip to content

Commit 87321c0

Browse files
authored
Add GitHub Actions for CI/CD automation (#163)
* Add GitHub Actions for CI/CD automation Composite YAML actions for B2C CLI operations: setup, run, code-deploy, mrt-deploy, job-run, and webdav-upload. Includes starter workflow templates, CI test workflow, and user guide documentation. * Remove redundant env vars from test workflow The setup action already sets SFCC_DISABLE_TELEMETRY and NO_COLOR via $GITHUB_ENV — no need to duplicate at the workflow level. * Keep telemetry enabled in setup action Only disable telemetry in our own test workflow, not for customers. * Move CI/CD guide under Authentication Setup in sidebar * Expand CI/CD guide overview with motivation and benefits * Simplify credential setup wording in CI/CD guide * Update quick start to show setup + code-deploy pattern * Add build steps and dynamic code version to quick start example * Remove CODE_VERSION from recommended variables Most use cases will derive the code version dynamically rather than storing it as a static repository variable. * Decouple --json flag from log format --json now only controls structured result output to stdout. Logs always use pino-pretty on stderr. A new --jsonl flag (with --json-logs alias and SFCC_JSON_LOGS env var) is available for users who explicitly want JSONL log output. In the run action, stderr is no longer merged into stdout so human-readable logs stream directly to the GitHub Actions step log. * Add log-level input to setup action The setup action now accepts a log-level input that sets SFCC_LOG_LEVEL for all subsequent steps. Test actions workflow uses trace level for maximum visibility. Document logging configuration in CI/CD guide and actions README. * Improve CI/CD guide: expand outputs examples, remove internals Add practical examples showing how to use fromJSON() to extract fields from code-deploy, job-run, and code-list results. Remove pino-pretty implementation detail from logging section. * Simplify Using Outputs examples in CI/CD guide Lead with direct output reference, only introduce fromJSON() where it's actually needed (conditional expressions, extracting fields). * Print command stdout to step log, fix outputs docs Restore echo of captured stdout in the run action so command output (help text, JSON results) appears in the GitHub Actions step log. Stderr already streams directly. Update the Using Outputs docs to show continue-on-error pattern for inspecting failed job results. * Stream command stdout in real-time using tee Replace buffered capture with tee + temp file so stdout streams to the step log as the command runs. Long-running commands like code deploy and job run --wait now show progress immediately instead of buffering until completion. * Add data-import action and update workflow template New high-level action that handles upload, job execution, waiting, and cleanup in a single step. Update the workflow template to use it. * Add plugins input to setup action Accept a list of plugins (one per line) to install after the CLI. Cache the oclif data directory (~/.local/share/b2c) alongside npm so plugin installs are reused across runs. * Add Plugins section to CI/CD guide * Add changeset for --json / --jsonl decoupling
1 parent 39bf4a3 commit 87321c0

File tree

22 files changed

+1717
-3
lines changed

22 files changed

+1717
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@salesforce/b2c-tooling-sdk': minor
3+
---
4+
5+
`--json` no longer switches log output to JSONL. Logs are always human-readable on stderr; `--json` only controls the structured result on stdout. Use the new `--jsonl` flag (or `SFCC_JSON_LOGS` env var) to get machine-readable log lines.

.changeset/github-actions.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@salesforce/b2c-cli': minor
3+
---
4+
5+
Add GitHub Actions for CI/CD automation: setup, run, code-deploy, mrt-deploy, job-run, and webdav-upload actions with starter workflow templates

.github/workflows/test-actions.yml

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
name: Test GitHub Actions
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'action.yml'
7+
- 'actions/**'
8+
- '.github/workflows/test-actions.yml'
9+
push:
10+
branches: [main]
11+
paths:
12+
- 'action.yml'
13+
- 'actions/**'
14+
- '.github/workflows/test-actions.yml'
15+
16+
env:
17+
SFCC_DISABLE_TELEMETRY: true
18+
SFCC_LOG_LEVEL: trace
19+
20+
jobs:
21+
# Smoke test: install CLI and verify
22+
setup-latest:
23+
name: 'Setup (latest)'
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Run setup action
29+
id: setup
30+
uses: ./actions/setup
31+
with:
32+
version: latest
33+
client-id: test-client-id
34+
server: test.example.com
35+
code-version: test_version
36+
37+
- name: Verify CLI installed
38+
run: b2c --version
39+
40+
- name: Verify env vars set
41+
run: |
42+
[ "$SFCC_CLIENT_ID" = "test-client-id" ] || (echo "SFCC_CLIENT_ID not set" && exit 1)
43+
[ "$SFCC_SERVER" = "test.example.com" ] || (echo "SFCC_SERVER not set" && exit 1)
44+
[ "$SFCC_CODE_VERSION" = "test_version" ] || (echo "SFCC_CODE_VERSION not set" && exit 1)
45+
[ "$NO_COLOR" = "1" ] || (echo "NO_COLOR not set" && exit 1)
46+
echo "All environment variables verified"
47+
48+
setup-nightly:
49+
name: 'Setup (nightly)'
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v4
53+
54+
- name: Run setup action with nightly
55+
uses: ./actions/setup
56+
with:
57+
version: nightly
58+
59+
- name: Verify CLI installed
60+
run: b2c --version
61+
62+
# Root action: setup + command
63+
root-action:
64+
name: 'Root action'
65+
runs-on: ubuntu-latest
66+
steps:
67+
- uses: actions/checkout@v4
68+
69+
- name: Run root action with command
70+
id: root
71+
uses: ./
72+
with:
73+
command: '--help'
74+
json: 'false'
75+
76+
- name: Verify output
77+
run: |
78+
echo "Exit code: ${{ steps.root.outputs.exit-code }}"
79+
[ "${{ steps.root.outputs.exit-code }}" = "0" ] || exit 1
80+
81+
# Root action: setup only (no command)
82+
root-setup-only:
83+
name: 'Root action (setup only)'
84+
runs-on: ubuntu-latest
85+
steps:
86+
- uses: actions/checkout@v4
87+
88+
- name: Run root action without command
89+
id: root
90+
uses: ./
91+
with:
92+
server: test.example.com
93+
94+
- name: Verify CLI available
95+
run: b2c --version
96+
97+
- name: Verify env var set
98+
run: |
99+
[ "$SFCC_SERVER" = "test.example.com" ] || exit 1
100+
101+
# Setup + run: two-step pattern
102+
setup-then-run:
103+
name: 'Setup + Run'
104+
runs-on: ubuntu-latest
105+
steps:
106+
- uses: actions/checkout@v4
107+
108+
- name: Setup
109+
uses: ./actions/setup
110+
111+
- name: Run help command
112+
id: run
113+
uses: ./actions/run
114+
with:
115+
command: '--help'
116+
json: 'false'
117+
118+
- name: Verify output
119+
run: |
120+
[ "${{ steps.run.outputs.exit-code }}" = "0" ] || exit 1
121+
122+
# High-level action smoke tests (--help to verify command construction)
123+
code-deploy-help:
124+
name: 'Code Deploy (help)'
125+
runs-on: ubuntu-latest
126+
steps:
127+
- uses: actions/checkout@v4
128+
129+
- name: Setup
130+
uses: ./actions/setup
131+
132+
- name: Test code deploy help
133+
uses: ./actions/run
134+
with:
135+
command: 'code deploy --help'
136+
json: 'false'
137+
138+
mrt-deploy-help:
139+
name: 'MRT Deploy (help)'
140+
runs-on: ubuntu-latest
141+
steps:
142+
- uses: actions/checkout@v4
143+
144+
- name: Setup
145+
uses: ./actions/setup
146+
147+
- name: Test mrt bundle deploy help
148+
uses: ./actions/run
149+
with:
150+
command: 'mrt bundle deploy --help'
151+
json: 'false'
152+
153+
job-run-help:
154+
name: 'Job Run (help)'
155+
runs-on: ubuntu-latest
156+
steps:
157+
- uses: actions/checkout@v4
158+
159+
- name: Setup
160+
uses: ./actions/setup
161+
162+
- name: Test job run help
163+
uses: ./actions/run
164+
with:
165+
command: 'job run --help'
166+
json: 'false'
167+
168+
data-import-help:
169+
name: 'Data Import (help)'
170+
runs-on: ubuntu-latest
171+
steps:
172+
- uses: actions/checkout@v4
173+
174+
- name: Setup
175+
uses: ./actions/setup
176+
177+
- name: Test job import help
178+
uses: ./actions/run
179+
with:
180+
command: 'job import --help'
181+
json: 'false'
182+
183+
webdav-upload-help:
184+
name: 'WebDAV Upload (help)'
185+
runs-on: ubuntu-latest
186+
steps:
187+
- uses: actions/checkout@v4
188+
189+
- name: Setup
190+
uses: ./actions/setup
191+
192+
- name: Test webdav put help
193+
uses: ./actions/run
194+
with:
195+
command: 'webdav put --help'
196+
json: 'false'
197+
198+
# E2E tests — only on main, requires e2e-dev environment with real credentials
199+
e2e:
200+
name: 'E2E'
201+
if: github.ref == 'refs/heads/main'
202+
runs-on: ubuntu-latest
203+
environment: e2e-dev
204+
steps:
205+
- uses: actions/checkout@v4
206+
207+
- name: Setup with real credentials
208+
uses: ./actions/setup
209+
with:
210+
client-id: ${{ secrets.SFCC_CLIENT_ID }}
211+
client-secret: ${{ secrets.SFCC_CLIENT_SECRET }}
212+
server: ${{ vars.SFCC_SERVER }}
213+
username: ${{ secrets.SFCC_USERNAME }}
214+
password: ${{ secrets.SFCC_PASSWORD }}
215+
216+
- name: List code versions
217+
id: code-list
218+
uses: ./actions/run
219+
with:
220+
command: 'code list'
221+
222+
- name: Verify code list output
223+
run: |
224+
echo "Result: ${{ steps.code-list.outputs.result }}"
225+
[ "${{ steps.code-list.outputs.exit-code }}" = "0" ] || exit 1

action.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: 'B2C Commerce Developer Tooling'
2+
description: 'Setup the Salesforce B2C Commerce CLI and optionally run a command'
3+
branding:
4+
icon: 'terminal'
5+
color: 'blue'
6+
7+
inputs:
8+
command:
9+
description: 'CLI command to run (omit for setup-only)'
10+
required: false
11+
version:
12+
description: 'CLI version to install (e.g. "latest", "0.4.1", "nightly")'
13+
required: false
14+
default: 'latest'
15+
node-version:
16+
description: 'Node.js version to install'
17+
required: false
18+
default: '22'
19+
json:
20+
description: 'Append --json flag and parse JSON output into the result output'
21+
required: false
22+
default: 'true'
23+
working-directory:
24+
description: 'Working directory for the command'
25+
required: false
26+
default: '.'
27+
client-id:
28+
description: 'OAuth Client ID → SFCC_CLIENT_ID'
29+
required: false
30+
client-secret:
31+
description: 'OAuth Client Secret → SFCC_CLIENT_SECRET'
32+
required: false
33+
server:
34+
description: 'B2C instance hostname → SFCC_SERVER'
35+
required: false
36+
code-version:
37+
description: 'Code version → SFCC_CODE_VERSION'
38+
required: false
39+
username:
40+
description: 'WebDAV username → SFCC_USERNAME'
41+
required: false
42+
password:
43+
description: 'WebDAV password/access key → SFCC_PASSWORD'
44+
required: false
45+
short-code:
46+
description: 'SCAPI short code → SFCC_SHORTCODE'
47+
required: false
48+
tenant-id:
49+
description: 'Tenant ID → SFCC_TENANT_ID'
50+
required: false
51+
mrt-api-key:
52+
description: 'MRT API key → SFCC_MRT_API_KEY'
53+
required: false
54+
mrt-project:
55+
description: 'MRT project slug → SFCC_MRT_PROJECT'
56+
required: false
57+
mrt-environment:
58+
description: 'MRT environment → SFCC_MRT_ENVIRONMENT'
59+
required: false
60+
account-manager-host:
61+
description: 'Account Manager hostname → SFCC_ACCOUNT_MANAGER_HOST'
62+
required: false
63+
64+
outputs:
65+
cli-version:
66+
description: 'Installed CLI version'
67+
value: ${{ steps.setup.outputs.cli-version }}
68+
result:
69+
description: 'Command output (JSON-parsed when json=true)'
70+
value: ${{ steps.command.outputs.result }}
71+
exit-code:
72+
description: 'Command exit code'
73+
value: ${{ steps.command.outputs.exit-code }}
74+
75+
runs:
76+
using: 'composite'
77+
steps:
78+
- name: Setup B2C CLI
79+
id: setup
80+
uses: ./actions/setup
81+
with:
82+
version: ${{ inputs.version }}
83+
node-version: ${{ inputs.node-version }}
84+
client-id: ${{ inputs.client-id }}
85+
client-secret: ${{ inputs.client-secret }}
86+
server: ${{ inputs.server }}
87+
code-version: ${{ inputs.code-version }}
88+
username: ${{ inputs.username }}
89+
password: ${{ inputs.password }}
90+
short-code: ${{ inputs.short-code }}
91+
tenant-id: ${{ inputs.tenant-id }}
92+
mrt-api-key: ${{ inputs.mrt-api-key }}
93+
mrt-project: ${{ inputs.mrt-project }}
94+
mrt-environment: ${{ inputs.mrt-environment }}
95+
account-manager-host: ${{ inputs.account-manager-host }}
96+
97+
- name: Run command
98+
id: command
99+
if: inputs.command != ''
100+
uses: ./actions/run
101+
with:
102+
command: ${{ inputs.command }}
103+
json: ${{ inputs.json }}
104+
working-directory: ${{ inputs.working-directory }}

0 commit comments

Comments
 (0)