-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.ts
54 lines (48 loc) · 1.4 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
53
54
import * as core from '@actions/core'
import App from './src/App'
import { AppProps, Errors } from './src/types/app.types'
export const configMsg = '. Configure Github secrets please'
export const run = (): void => {
try {
const errors: string[] = []
const {
nowUsername = '',
nowPassword = '',
nowSourceInstance = '',
appSysID = '',
appScope = '',
branch = '',
} = process.env
if (!nowUsername) {
errors.push(Errors.USERNAME)
}
if (!nowPassword) {
errors.push(Errors.PASSWORD)
}
if (!nowSourceInstance) {
errors.push(Errors.INSTANCE)
}
if (!appSysID && !appScope) {
errors.push(Errors.SYSID_OR_SCOPE)
}
if (errors.length) {
core.setFailed(`${errors.join('. ')}${configMsg}`)
} else {
const props: AppProps = {
appSysID,
scope: appScope,
username: nowUsername,
password: nowPassword,
nowSourceInstance: nowSourceInstance,
branch: branch,
}
const app = new App(props)
app.applyChanges().catch(error => {
core.setFailed(error.message)
})
}
} catch (error) {
core.setFailed(error.message)
}
}
run()