forked from PGYER/pgyer-upload-app-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
59 lines (50 loc) · 1.48 KB
/
index.js
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
55
56
57
58
59
const core = require('@actions/core');
const github = require('@actions/github');
const PGYERAppUploader = require('./PGYERAppUploader');
try {
const uploadOptions = {
log: false,
}
const apiKey = core.getInput('_api_key', { required: true });
if (!apiKey) {
core.warning('apiKey was not set');
}
const appFilePath = core.getInput('appFilePath', { required: true });
if (!appFilePath) {
core.warning('appFilePath was not set');
}
uploadOptions.filePath = appFilePath;
const otherParams = [
"buildInstallType",
"buildPassword",
"buildUpdateDescription",
"buildInstallDate",
"buildInstallStartDate",
"buildInstallEndDate",
"buildChannelShortcut"
];
otherParams.forEach(name => {
let value = core.getInput(name);
if (value) {
uploadOptions[[name]] = value;
core.info(`set ${name}: ${value}`);
}
});
const ext = appFilePath.split('.').pop().toLowerCase();
if (ext == 'ipa') {
uploadOptions.buildType = 'ios';
} else if (ext == 'apk') {
uploadOptions.buildType = 'android';
} else {
core.warning(`Unsupported file type: ${ext}`);
}
core.info(`filePath: ${appFilePath}`);
core.info(`buildType: ${uploadOptions.buildType}`);
const uploader = new PGYERAppUploader(apiKey);
uploader.upload(uploadOptions).then(function (info) {
core.info(`upload success. app info:`);
//core.info(JSON.stringify(info));
}).catch(console.error);
} catch (error) {
core.setFailed(error.message);
}