Skip to content

Commit 51afe51

Browse files
committed
add installOnly option and login to square cloud automatically
1 parent 76bcbf5 commit 51afe51

5 files changed

Lines changed: 21 additions & 4 deletions

File tree

action.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ inputs:
1010
required: true
1111
description: 'Square Cloud API token'
1212
command:
13-
required: true
14-
description: 'Arguments to pass to Square Cloud CLI'
13+
required: false
14+
description: 'Commands to pass to Square Cloud CLI'
15+
install-only:
16+
required: false
17+
default: 'false'
18+
description: 'Install only Square Cloud CLI and add to path'
1519
workdir:
1620
required: false
1721
default: "."

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
},
2626
"dependencies": {
2727
"@actions/core": "^1.10.1",
28+
"@actions/exec": "^1.1.1",
2829
"@actions/tool-cache": "^2.0.1",
2930
"@octokit/rest": "^20.0.2"
3031
},

src/context.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ export interface ActionInputs {
55
token: string;
66
command: string;
77
workdir: string;
8+
installOnly: boolean;
89
}
910

1011
export function getInputs(): ActionInputs {
1112
return {
1213
token: core.getInput("token", { required: true }),
1314
command: core.getInput("command", { required: true }),
1415
workdir: core.getInput("cwd") || ".",
16+
installOnly: core.getBooleanInput("install-only") || false,
1517
}
1618
}
1719

src/index.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { install } from "./cli";
66

77
async function run(): Promise<void> {
88
try {
9-
const { workdir: cwd, command, token } = getInputs()
9+
const { workdir: cwd, command, token, installOnly } = getInputs()
1010

1111
const cliBinary = await install()
1212
core.info(`CLI Installed successfully`)
@@ -16,7 +16,16 @@ async function run(): Promise<void> {
1616
process.chdir(cwd)
1717
}
1818

19-
await exec.exec(`${cliBinary} --token=${token} ${command}`)
19+
await exec.exec(`${cliBinary} login --token=${token}`)
20+
core.debug(`Successfully logged to Square Cloud`)
21+
22+
if (installOnly) {
23+
core.addPath(cliBinary)
24+
core.debug(`Added ${cliBinary} to path`)
25+
return
26+
}
27+
28+
await exec.exec(`${cliBinary} ${command}`)
2029
} catch (error) {
2130
if (error instanceof Error) core.setFailed(error.message);
2231
else core.setFailed("Unknown error");

0 commit comments

Comments
 (0)