Skip to content

Commit

Permalink
install platform.sh cli
Browse files Browse the repository at this point in the history
  • Loading branch information
zeshanziya committed Jun 3, 2024
1 parent 3f9efa9 commit 6145af6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
import * as core from '@actions/core'
import { exec } from '@actions/exec'

/**
* The main function for the action.
* @returns {Promise<void>} Resolves when the action is complete.
*/
export async function run(): Promise<void> {
const action = core.getInput('action')
if (!['deploy', 'clean'].includes(action)) {
throw new Error('Invalid action to perform')
}

core.startGroup('Install Platform.sh cli')
const cliVersion = core.getInput('cli-version')
let cliInstallUrl =
'curl -fsSL https://raw.githubusercontent.com/platformsh/cli/main/installer.sh | bash'
if (cliVersion !== 'latest') {
// Validate version input to prevent command injection
if (!/^[\d.]+$/.test(cliVersion)) {
throw new Error(
'Invalid version format. Only numbers and dots are allowed.'
)
}
cliInstallUrl = `curl -fsSL https://raw.githubusercontent.com/platformsh/cli/main/installer.sh | VERSION=${cliVersion} bash`
}
await exec(cliInstallUrl)
core.endGroup()

core.info('Inside custom action')
}

0 comments on commit 6145af6

Please sign in to comment.