-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f9efa9
commit 6145af6
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
} |