forked from ServiceNow/sncicd-plugin-rollback
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
42 lines (36 loc) · 1.13 KB
/
index.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
// import * as github from '@actions/github'
import * as core from '@actions/core'
import { AppProps, Errors } from './src/App.types'
import App from './src/App'
export const configMsg = '. Configure Github secrets please'
export const run = (): void => {
try {
const errors: string[] = []
const { nowUsername = '', nowPassword = '', nowInstallInstance = '' } = process.env
if (!nowUsername) {
errors.push(Errors.USERNAME)
}
if (!nowPassword) {
errors.push(Errors.PASSWORD)
}
if (!nowInstallInstance) {
errors.push(Errors.INSTALL_INSTANCE)
}
if (errors.length) {
core.setFailed(`${errors.join('. ')}${configMsg}`)
} else {
const props: AppProps = {
nowInstallInstance,
username: nowUsername,
password: nowPassword,
}
const app = new App(props)
app.rollbackPlugin().catch(error => {
core.setFailed(error.message)
})
}
} catch (error) {
core.setFailed(error.message)
}
}
run()