mirror of
https://github.com/werf/actions.git
synced 2026-02-05 10:56:23 +03:00
Merge pull request #2 from flant/refactor
Refactor: combine common actions code into one function
This commit is contained in:
File diff suppressed because it is too large
Load Diff
11728
cleanup/index.js
11728
cleanup/index.js
File diff suppressed because it is too large
Load Diff
11729
converge/index.js
11729
converge/index.js
File diff suppressed because it is too large
Load Diff
11729
deploy/index.js
11729
deploy/index.js
File diff suppressed because it is too large
Load Diff
11729
dismiss/index.js
11729
dismiss/index.js
File diff suppressed because it is too large
Load Diff
@@ -1,31 +1,9 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import {Manager} from './manager'
|
import {PrepareEnvironAndRunWerfCommand} from './common'
|
||||||
import {
|
|
||||||
ProcessGitHubContext,
|
|
||||||
SetupKubeConfig,
|
|
||||||
ValidateWerfVersion
|
|
||||||
} from './common'
|
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
ProcessGitHubContext()
|
await PrepareEnvironAndRunWerfCommand(['build-and-publish'])
|
||||||
|
|
||||||
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 =
|
|
||||||
process.env.GITHUB_TOKEN || core.getInput('github-token')
|
|
||||||
await m.PerformCIEnv()
|
|
||||||
|
|
||||||
await m.Exec(['build-and-publish'])
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message)
|
core.setFailed(error.message)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,9 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import {Manager} from './manager'
|
import {PrepareEnvironAndRunWerfCommand} from './common'
|
||||||
import {
|
|
||||||
ProcessGitHubContext,
|
|
||||||
SetupKubeConfig,
|
|
||||||
ValidateWerfVersion
|
|
||||||
} from './common'
|
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
ProcessGitHubContext()
|
await PrepareEnvironAndRunWerfCommand(['cleanup'])
|
||||||
|
|
||||||
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'])
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message)
|
core.setFailed(error.message)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,37 @@ import * as fs from 'fs'
|
|||||||
import * as semver from 'semver'
|
import * as semver from 'semver'
|
||||||
import {context} from '@actions/github'
|
import {context} from '@actions/github'
|
||||||
import {String} from 'typescript-string-operations'
|
import {String} from 'typescript-string-operations'
|
||||||
|
import {Manager} from './manager'
|
||||||
|
|
||||||
const minimalWerfVersion = 'v1.1.17'
|
const minimalWerfVersion = 'v1.1.17'
|
||||||
|
|
||||||
|
export async function PrepareEnvironAndRunWerfCommand(
|
||||||
|
args: string[]
|
||||||
|
): 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 =
|
||||||
|
process.env.GITHUB_TOKEN || core.getInput('github-token')
|
||||||
|
await m.PerformCIEnv()
|
||||||
|
|
||||||
|
await m.Exec(args)
|
||||||
|
} catch (error) {
|
||||||
|
core.setFailed(error.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function SetupKubeConfig(
|
export async function SetupKubeConfig(
|
||||||
kubeConfigBase64Data: string
|
kubeConfigBase64Data: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
|||||||
@@ -1,32 +1,10 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import {Manager} from './manager'
|
import {PrepareEnvironAndRunWerfCommand} from './common'
|
||||||
import {
|
|
||||||
ProcessGitHubContext,
|
|
||||||
SetupKubeConfig,
|
|
||||||
ValidateWerfVersion
|
|
||||||
} from './common'
|
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
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 =
|
|
||||||
process.env.GITHUB_TOKEN || core.getInput('github-token')
|
|
||||||
await m.PerformCIEnv()
|
|
||||||
|
|
||||||
process.env.WERF_ENV = core.getInput('env')
|
process.env.WERF_ENV = core.getInput('env')
|
||||||
await m.Exec(['converge'])
|
await PrepareEnvironAndRunWerfCommand(['converge'])
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message)
|
core.setFailed(error.message)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +1,10 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import {Manager} from './manager'
|
import {PrepareEnvironAndRunWerfCommand} from './common'
|
||||||
import {
|
|
||||||
ProcessGitHubContext,
|
|
||||||
SetupKubeConfig,
|
|
||||||
ValidateWerfVersion
|
|
||||||
} from './common'
|
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
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 =
|
|
||||||
process.env.GITHUB_TOKEN || core.getInput('github-token')
|
|
||||||
await m.PerformCIEnv()
|
|
||||||
|
|
||||||
process.env.WERF_ENV = core.getInput('env')
|
process.env.WERF_ENV = core.getInput('env')
|
||||||
await m.Exec(['deploy'])
|
await PrepareEnvironAndRunWerfCommand(['deploy'])
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message)
|
core.setFailed(error.message)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +1,10 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import {Manager} from './manager'
|
import {PrepareEnvironAndRunWerfCommand} from './common'
|
||||||
import {
|
|
||||||
ProcessGitHubContext,
|
|
||||||
SetupKubeConfig,
|
|
||||||
ValidateWerfVersion
|
|
||||||
} from './common'
|
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
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 =
|
|
||||||
process.env.GITHUB_TOKEN || core.getInput('github-token')
|
|
||||||
await m.PerformCIEnv()
|
|
||||||
|
|
||||||
process.env.WERF_ENV = core.getInput('env')
|
process.env.WERF_ENV = core.getInput('env')
|
||||||
await m.Exec(['dismiss'])
|
await PrepareEnvironAndRunWerfCommand(['dismiss'])
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message)
|
core.setFailed(error.message)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user