-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
65 lines (58 loc) · 2.33 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: SFDX Login
description: Salesforce login action that either uses a SFDX Auth URL or the JWT based login flow.
branding:
icon: log-in
color: blue
inputs:
sfdx-url:
description: >
Authorize an org using a Base64 encoded Salesforce DX (SFDX) authorization URL.
The SFDX authorization URL must have the format "force://<clientId>:<clientSecret>:<refreshToken>@<instanceUrl>".
NOTE: The SFDX authorization URL uses the "force" protocol, and not "http" or "https".
Also, the "instanceUrl" inside the SFDX authorization URL doesn't include the protocol ("https://").
required: false
client-id:
description: OAuth client ID (also called consumer key) of the custom connected app for the JWT login flow.
required: false
jwt-secret-key:
description: Contents of the server.key file containing the private key for the JWT login flow.
required: false
username:
description: Username of the user logging in for the JWT login flow.
required: false
set-default-dev-hub:
description: Set the authenticated org as the default Dev Hub.
required: false
default: 'false'
set-default:
description: Set the authenticated org as the default that all org-related commands run against.
required: false
default: 'true'
alias:
description: Alias for the org.
required: false
runs:
using: composite
steps:
- name: Salesforce Org Login
shell: bash
run: |
args=()
if [[ "${{ inputs.set-default-dev-hub }}" == "true" ]]; then
args+=(--set-default-dev-hub)
fi
if [[ "${{ inputs.set-default }}" == "true" ]]; then
args+=(--set-default)
fi
if [[ -n "${{ inputs.alias }}" ]]; then
args+=(--alias "${{ inputs.alias }}")
fi
if [[ -n "${{ inputs.sfdx-url }}" ]];then
echo "Log in to Salesforce org using Salesforce DX authorization URL..."
echo ${{ inputs.sfdx-url }} | base64 --decode | jq > authFile.json
sf org login sfdx-url --sfdx-url-file "authFile.json" "${args[@]}"
else
echo "Log in to Salesforce org using JSON web token (JWT)..."
echo "${{ inputs.jwt-secret-key }}" > server.key
sf org login jwt --client-id ${{ inputs.client-id }} --jwt-key-file server.key --username ${{ inputs.username }} "${args[@]}"
fi