-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
37 lines (34 loc) · 1.42 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
import * as core from '@actions/core';
import { getFilesForUpload } from './src/file-system-utils';
import { uploadAll } from './src/azure-upload-utils';
import { LocalFileMapping, EntraAppConfiguration, JobParamDirectoryUpload } from './src/types';
try {
/**
* File types to upload should look like
* { ".html": "text/html" }
*/
const fileTypesToUpload = JSON.parse(core.getInput('fileTypesToUpload'));
/**
* Directories to upload should look like
* [
* { directoryToUpload: "", shouldRecurse: "", baseContainerPath: "" }
* ]
*/
const directoriesToUpload: JobParamDirectoryUpload = JSON.parse(core.getInput('directoriesToUpload')) || [];
let filesToUpload: Array<LocalFileMapping> = [];
directoriesToUpload.forEach(t => {
filesToUpload = filesToUpload.concat(getFilesForUpload(t.directoryToUpload, t.shouldRecurse, t.baseContainerPath, Object.keys(fileTypesToUpload)));
});
// build entra auth configuration
const entraAppConfiguration: EntraAppConfiguration = {
clientId: core.getInput('clientId'),
clientSecret: core.getInput('clientSecret'),
tenantId: core.getInput('tenantId')
};
const storageAccountList: Array<string> = JSON.parse(core.getInput('storageAccountList'));
const containerName = core.getInput('containerName');
uploadAll(storageAccountList, containerName, entraAppConfiguration, filesToUpload, fileTypesToUpload);
}
catch (error) {
core.setFailed(error.message);
}