support install without config

This commit is contained in:
Rimo
2024-01-26 14:27:47 +00:00
parent 59fe15c39c
commit fdb656e148
3 changed files with 82 additions and 60 deletions

View File

@@ -9,22 +9,22 @@ branding:
# Define your inputs here. # Define your inputs here.
inputs: inputs:
ossutil-version:
description: 'The OSSUTIL version to download and use, or "latest" for the latest version.'
required: true
default: '1.7.14'
endpoint: endpoint:
description: 'The endpoint of your bucket' description: 'The endpoint of your bucket'
required: true required: false
access-key-id: access-key-id:
description: 'The AccessKey ID of the credentials' description: 'The AccessKey ID of the credentials'
required: true required: false
access-key-secret: access-key-secret:
description: 'The AccessKey Secret of the credentials' description: 'The AccessKey Secret of the credentials'
required: true required: false
sts-token: sts-token:
description: 'The STS Token of the credentials' description: 'The STS Token of the credentials'
required: false required: false
ossutil-version:
description: 'The OSSUTIL version to download and use, or "latest" for the latest version.'
required: false
default: '1.7.14'
github-token: github-token:
description: 'The GitHub token used to call API to fetch the latest version info' description: 'The GitHub token used to call API to fetch the latest version info'
required: false required: false

38
dist/index.js generated vendored
View File

@@ -32940,16 +32940,29 @@ const installer = __importStar(__nccwpck_require__(2574));
*/ */
async function run() { async function run() {
try { try {
// download install();
const version = core.getInput('ossutil-version'); config();
}
catch (error) {
// Fail the workflow run if an error occurs
if (error instanceof Error)
core.setFailed(error.message);
}
}
exports.run = run;
async function install() {
const version = core.getInput('ossutil-version', { required: true });
await installer.installOssutil(version); await installer.installOssutil(version);
core.info('ossutil is successfully installed'); core.info('ossutil is successfully installed');
// config }
const inputOptions = { required: true }; async function config() {
const endpoint = core.getInput('endpoint', inputOptions); const endpoint = core.getInput('endpoint');
const accessKeyId = core.getInput('access-key-id', inputOptions); if (endpoint.length == 0) {
const accessKeySecret = core.getInput('access-key-secret', inputOptions); core.info('ossutil config is skipped');
const stsToken = core.getInput('sts-token'); return;
}
const accessKeyId = core.getInput('access-key-id', { required: true });
const accessKeySecret = core.getInput('access-key-secret', { required: true });
const args = [ const args = [
'config', 'config',
'--endpoint', '--endpoint',
@@ -32959,6 +32972,7 @@ async function run() {
'--access-key-secret', '--access-key-secret',
accessKeySecret accessKeySecret
]; ];
const stsToken = core.getInput('sts-token');
if (stsToken) { if (stsToken) {
args.push('--sts-token', stsToken); args.push('--sts-token', stsToken);
} }
@@ -32966,14 +32980,10 @@ async function run() {
if (exitCode === 0) { if (exitCode === 0) {
core.info('ossutil config is done'); core.info('ossutil config is done');
} }
} else {
catch (error) { core.error('ossutil config is failed with exit code: ' + exitCode);
// Fail the workflow run if an error occurs
if (error instanceof Error)
core.setFailed(error.message);
} }
} }
exports.run = run;
/***/ }), /***/ }),

View File

@@ -8,17 +8,29 @@ import * as installer from './installer'
*/ */
export async function run(): Promise<void> { export async function run(): Promise<void> {
try { try {
// download install()
const version = core.getInput('ossutil-version') config()
} catch (error) {
// Fail the workflow run if an error occurs
if (error instanceof Error) core.setFailed(error.message)
}
}
async function install(): Promise<void> {
const version = core.getInput('ossutil-version', { required: true })
await installer.installOssutil(version) await installer.installOssutil(version)
core.info('ossutil is successfully installed') core.info('ossutil is successfully installed')
}
// config async function config(): Promise<void> {
const inputOptions: core.InputOptions = { required: true } const endpoint = core.getInput('endpoint')
const endpoint = core.getInput('endpoint', inputOptions) if (endpoint.length === 0) {
const accessKeyId = core.getInput('access-key-id', inputOptions) core.info('ossutil config is skipped')
const accessKeySecret = core.getInput('access-key-secret', inputOptions) return
const stsToken = core.getInput('sts-token') }
const accessKeyId = core.getInput('access-key-id', { required: true })
const accessKeySecret = core.getInput('access-key-secret', { required: true })
const args = [ const args = [
'config', 'config',
'--endpoint', '--endpoint',
@@ -28,15 +40,15 @@ export async function run(): Promise<void> {
'--access-key-secret', '--access-key-secret',
accessKeySecret accessKeySecret
] ]
const stsToken = core.getInput('sts-token')
if (stsToken) { if (stsToken) {
args.push('--sts-token', stsToken) args.push('--sts-token', stsToken)
} }
const exitCode = await exec.exec('ossutil', args) const exitCode = await exec.exec('ossutil', args)
if (exitCode === 0) { if (exitCode === 0) {
core.info('ossutil config is done') core.info('ossutil config is done')
} } else {
} catch (error) { core.error(`ossutil config is failed with exit code: ${exitCode}`)
// Fail the workflow run if an error occurs
if (error instanceof Error) core.setFailed(error.message)
} }
} }