-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.ts
52 lines (47 loc) · 1.38 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
43
44
45
46
47
48
49
50
51
52
// 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 = '',
appSysID = '',
appScope = '',
} = process.env
if (!nowUsername) {
errors.push(Errors.USERNAME)
}
if (!nowPassword) {
errors.push(Errors.PASSWORD)
}
if (!nowInstallInstance) {
errors.push(Errors.INSTALL_INSTANCE)
}
if (!appScope && !appSysID) {
errors.push(Errors.SYSID_OR_SCOPE)
}
if (errors.length) {
core.setFailed(`${errors.join('. ')}${configMsg}`)
} else {
const props: AppProps = {
appSysID,
nowInstallInstance,
username: nowUsername,
password: nowPassword,
scope: appScope,
}
const app = new App(props)
app.rollbackApp().catch(error => {
core.setFailed(error.message)
})
}
} catch (error) {
core.setFailed(error.message)
}
}
run()