generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
45 lines (38 loc) · 1.27 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import * as core from '@actions/core'
import * as exec from '@actions/exec'
import * as fs from 'fs'
import * as https from 'https'
import * as path from 'path'
import { homedir } from 'os'
import { Cli, CliVersion } from './cliCommand'
import { CliDownloader } from './cliDownloader'
/**
* The main function for the action.
* @returns {Promise<void>} Resolves when the action is complete.
*/
export async function run(): Promise<void> {
try {
const flagshipDir = 'flagship'
const binaryDir = `${flagshipDir}/${CliVersion}`
const internalFlagshipDir = '/home/runner/.flagship'
const internalConfigutations = `${internalFlagshipDir}/configurations`
if (!fs.existsSync(internalFlagshipDir)) {
fs.mkdirSync(internalFlagshipDir)
}
fs.chmodSync(`${internalFlagshipDir}`, '777')
if (!fs.existsSync(internalConfigutations)) {
fs.mkdirSync(internalConfigutations)
}
fs.chmodSync(`${internalConfigutations}`, '777')
if (!fs.existsSync(binaryDir)) {
await CliDownloader(binaryDir)
}
const cli = new Cli()
const commandResponse = await cli.Resource(
core.getInput('resource'),
core.getInput('method'),
core.getInput('flags')
)
core.setOutput('COMMAND_RESPONSE', commandResponse)
} catch (err) {}
}