Refactor: combine common actions code into one function

This commit is contained in:
Alexey Igrychev
2020-05-28 07:48:22 +01:00
parent 78fed453af
commit 55e5f8823b
11 changed files with 29388 additions and 29413 deletions

View File

@@ -1,30 +1,9 @@
import * as core from '@actions/core'
import {Manager} from './manager'
import {
ProcessGitHubContext,
SetupKubeConfig,
ValidateWerfVersion
} from './common'
import {PrepareEnvironAndRunWerfCommand} from './common'
async function run(): Promise<void> {
try {
ProcessGitHubContext()
const kubeConfigBase64Data = core.getInput('kube-config-base64-data')
if (kubeConfigBase64Data !== '') {
SetupKubeConfig(kubeConfigBase64Data)
}
const m = new Manager()
await m.Install()
const versionOutput = await m.GetOutput(['version'])
ValidateWerfVersion(versionOutput)
process.env.GITHUB_TOKEN = core.getInput('github-token')
await m.PerformCIEnv()
await m.Exec(['cleanup'])
await PrepareEnvironAndRunWerfCommand(['cleanup'])
} catch (error) {
core.setFailed(error.message)
}