From a44e71649e05e4f48bb4ddaa3a59b4dc4c6815e8 Mon Sep 17 00:00:00 2001 From: David Esposito Date: Thu, 8 Apr 2021 14:59:23 -0400 Subject: [PATCH 1/5] #7 - updates location of tarball and manually updates the PATH per https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#adding-a-system-path now that there's no longer an install script for sfdx --- index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index c9b4613..4d8e9d1 100644 --- a/index.js +++ b/index.js @@ -9,12 +9,12 @@ try { } function installSFDX(){ - var download = 'wget https://developer.salesforce.com/media/salesforce-cli/sfdx-linux-amd64.tar.xz -P /tmp' + var download = 'wget https://developer.salesforce.com/media/salesforce-cli/sfdx/channels/stable/sfdx-linux-x64.tar.xz -P /tmp' var createDir = 'mkdir sfdx' var unzip = 'tar xJf /tmp/sfdx-linux-amd64.tar.xz -C sfdx --strip-components 1' - var install = './sfdx/install' - var clean = 'rm -r ./sfdx' - exec(download+' && '+createDir+' && '+unzip+' && '+install+' && '+clean, function(error, stdout, stderr){ + var install = 'echo "`pwd`/sfdx/bin" >> $GITHUB_PATH' + var version = 'sfdx/bin/sfdx --version' + exec(download+' && '+createDir+' && '+unzip+' && '+install+' && '+version, function(error, stdout, stderr){ if(error) throw(stderr) core.debug(stdout) if(core.getInput('sfdx-auth-url')) createAuthFile() @@ -27,8 +27,8 @@ function createAuthFile(){ } function authSFDX(){ - var params = '--setdefaultdevhubusername --setdefaultusername -a SFDX-ENV' - exec('sfdx auth:sfdxurl:store -f /tmp/sfdx_auth.txt '+params, function(error, stdout, stderr){ + var params = '--setdefaultdevhubusername -a SFDX-ENV' + exec('sfdx/bin/sfdx auth:sfdxurl:store -f /tmp/sfdx_auth.txt '+params, function(error, stdout, stderr){ if(error) throw(stderr) core.debug(stdout) }) From 899a2b79800d7b3dcc4a5679ec5bfc0bec11c2e8 Mon Sep 17 00:00:00 2001 From: David Esposito Date: Thu, 8 Apr 2021 15:06:06 -0400 Subject: [PATCH 2/5] #7 - update name of tarball --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 4d8e9d1..40e8c29 100644 --- a/index.js +++ b/index.js @@ -11,7 +11,7 @@ try { function installSFDX(){ var download = 'wget https://developer.salesforce.com/media/salesforce-cli/sfdx/channels/stable/sfdx-linux-x64.tar.xz -P /tmp' var createDir = 'mkdir sfdx' - var unzip = 'tar xJf /tmp/sfdx-linux-amd64.tar.xz -C sfdx --strip-components 1' + var unzip = 'tar xJf /tmp/sfdx-linux-x64.tar.xz -C sfdx --strip-components 1' var install = 'echo "`pwd`/sfdx/bin" >> $GITHUB_PATH' var version = 'sfdx/bin/sfdx --version' exec(download+' && '+createDir+' && '+unzip+' && '+install+' && '+version, function(error, stdout, stderr){ From 45df417193436c86fe2cf29442edf2c740db6f4f Mon Sep 17 00:00:00 2001 From: David Esposito Date: Thu, 8 Apr 2021 15:35:12 -0400 Subject: [PATCH 3/5] #7 - restores the params for sfdxurl:store since that's a breaking change --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 40e8c29..baca614 100644 --- a/index.js +++ b/index.js @@ -27,7 +27,7 @@ function createAuthFile(){ } function authSFDX(){ - var params = '--setdefaultdevhubusername -a SFDX-ENV' + var params = '--setdefaultdevhubusername --setdefaultusername -a SFDX-ENV' exec('sfdx/bin/sfdx auth:sfdxurl:store -f /tmp/sfdx_auth.txt '+params, function(error, stdout, stderr){ if(error) throw(stderr) core.debug(stdout) From 073a6d5435e0abfc01735870081666743e46a05a Mon Sep 17 00:00:00 2001 From: David Esposito Date: Thu, 8 Apr 2021 15:47:04 -0400 Subject: [PATCH 4/5] #7 - log more of the SFDX output to STDOUT so it shows up in the action logs --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index baca614..8dd8ec1 100644 --- a/index.js +++ b/index.js @@ -9,14 +9,14 @@ try { } function installSFDX(){ - var download = 'wget https://developer.salesforce.com/media/salesforce-cli/sfdx/channels/stable/sfdx-linux-x64.tar.xz -P /tmp' + var download = 'wget https://developer.salesforce.com/media/salesforce-cli/sfdx/channels/stable/sfdx-linux-x64.tar.xz -q -P /tmp' var createDir = 'mkdir sfdx' var unzip = 'tar xJf /tmp/sfdx-linux-x64.tar.xz -C sfdx --strip-components 1' var install = 'echo "`pwd`/sfdx/bin" >> $GITHUB_PATH' - var version = 'sfdx/bin/sfdx --version' + var version = 'sfdx/bin/sfdx --version && sfdx/bin/sfdx plugins --core' exec(download+' && '+createDir+' && '+unzip+' && '+install+' && '+version, function(error, stdout, stderr){ if(error) throw(stderr) - core.debug(stdout) + core.info(stdout) if(core.getInput('sfdx-auth-url')) createAuthFile() }) } @@ -30,7 +30,7 @@ function authSFDX(){ var params = '--setdefaultdevhubusername --setdefaultusername -a SFDX-ENV' exec('sfdx/bin/sfdx auth:sfdxurl:store -f /tmp/sfdx_auth.txt '+params, function(error, stdout, stderr){ if(error) throw(stderr) - core.debug(stdout) + core.info(stdout) }) } From c3802479ecb6ac5ea3e886ff633758d28eb0df22 Mon Sep 17 00:00:00 2001 From: David Esposito Date: Wed, 8 Sep 2021 16:20:36 -0400 Subject: [PATCH 5/5] PMGR-9933 -- adds support for an additional Input to the GH Action specifying an alternative tarball to install for the CLI; useful for when 'latest' is hopelessly broken --- action.yml | 3 +++ index.js | 13 +++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index b360dc1..8976395 100644 --- a/action.yml +++ b/action.yml @@ -5,6 +5,9 @@ inputs: sfdx-auth-url: description: Authorize a Salesforce org using an SFDX auth URL required: false + tarball-url: + description: Supply a URL to a XZip'd tarball containing the version of the SFDX CLI to install. If omitted or blank, it will install the "latest" CLI + required: false runs: using: 'node12' main: 'index.js' diff --git a/index.js b/index.js index 8dd8ec1..b246a2f 100644 --- a/index.js +++ b/index.js @@ -9,9 +9,18 @@ try { } function installSFDX(){ - var download = 'wget https://developer.salesforce.com/media/salesforce-cli/sfdx/channels/stable/sfdx-linux-x64.tar.xz -q -P /tmp' + var tarballBase = 'https://developer.salesforce.com/media/salesforce-cli/sfdx/channels/stable' + var tarballFile = 'sfdx-linux-x64.tar.xz' + + var tarballOverride = core.getInput('tarball-url') + if(tarballOverride ){ + tarballBase = tarballOverride.substr(0,tarballOverride.lastIndexOf('/')) + tarballFile = tarballOverride.substr(tarballOverride.lastIndexOf('/')+1) + } + + var download = 'wget ' + tarballBase + '/' + tarballFile + ' -q -P /tmp' var createDir = 'mkdir sfdx' - var unzip = 'tar xJf /tmp/sfdx-linux-x64.tar.xz -C sfdx --strip-components 1' + var unzip = 'tar xJf /tmp/' + tarballFile + ' -C sfdx --strip-components 1' var install = 'echo "`pwd`/sfdx/bin" >> $GITHUB_PATH' var version = 'sfdx/bin/sfdx --version && sfdx/bin/sfdx plugins --core' exec(download+' && '+createDir+' && '+unzip+' && '+install+' && '+version, function(error, stdout, stderr){