diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7f80813..3b35e98 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,7 +5,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, ubuntu-16.04, macos-latest, windows-latest, windows-2016] + os: [ubuntu-latest, ubuntu-18.04, macos-latest, windows-latest, windows-2016] name: Install the cli steps: - name: Checkout @@ -15,4 +15,3 @@ jobs: id: install - name: Test CLI run: doppler --version - diff --git a/index.js b/index.js index b91b2d3..3331dd0 100644 --- a/index.js +++ b/index.js @@ -1,15 +1,14 @@ const core = require('@actions/core'); const tc = require('@actions/tool-cache'); const io = require('@actions/io'); +const { execSync } = require('child_process'); const workspace = process.env.GITHUB_WORKSPACE; const binDir = `${workspace}/bin`; -try { - run(); -} catch (error) { +run().catch(error => { core.setFailed(error.message); -} +}) async function run() { switch (process.platform) { @@ -18,14 +17,9 @@ async function run() { await installZip(binDir, url); break; } - case "linux": { - const url = "https://cli.doppler.com/download?os=linux&arch=amd64&format=tar"; - await installTar(binDir, url); - break; - } + case "linux": case "darwin": { - const url = "https://cli.doppler.com/download?os=macos&arch=amd64&format=tar"; - await installTar(binDir, url); + await executeInstallSh(binDir) break; } default: { @@ -34,16 +28,25 @@ async function run() { } } -async function installTar(path, url) { +async function installZip(path, url) { await io.mkdirP(path); const downloadPath = await tc.downloadTool(url); - await tc.extractTar(downloadPath, path); + await tc.extractZip(downloadPath, path); core.addPath(path); } -async function installZip(path, url) { - await io.mkdirP(path); +async function executeInstallSh(installPath) { + // download script + const url = "https://cli.doppler.com/install.sh"; const downloadPath = await tc.downloadTool(url); - await tc.extractZip(downloadPath, path); - core.addPath(path); + execSync(`chmod +x ${downloadPath}`); + + // execute script + await io.mkdirP(installPath); + const installCommand = `${downloadPath} --debug --no-package-manager --install-path ${installPath}` + stdout = execSync(installCommand, { timeout: 15000 }); + console.log(Buffer.from(stdout).toString("utf-8")) + + // add binary to PATH + core.addPath(installPath); } diff --git a/package-lock.json b/package-lock.json index dbc8f10..fd62af5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "cli-action", - "version": "1.0.1", + "version": "1.0.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 24e2c7a..034bffc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cli-action", - "version": "1.0.1", + "version": "1.0.2", "description": "GitHub Action to install the Doppler CLI", "main": "index.js", "scripts": {