1
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2024-10-17 14:44:42 +02:00

Clean up actionUtils.ts a little

This commit is contained in:
Dan Blanchard 2023-08-31 14:14:17 -04:00
parent 9420979f7c
commit e6e13d9c52
No known key found for this signature in database

View file

@ -1,9 +1,8 @@
import * as cache from "@actions/cache"; import * as cache from "@actions/cache";
import * as core from "@actions/core"; import * as core from "@actions/core";
import { S3ClientConfig } from "@aws-sdk/client-s3";
import { Inputs, Outputs, RefKey, State } from "../constants"; import { Inputs, RefKey } from "../constants";
import {CommonPrefix, InputSerialization, S3ClientConfig} from "@aws-sdk/client-s3";
export function isGhes(): boolean { export function isGhes(): boolean {
const ghUrl = new URL( const ghUrl = new URL(
@ -82,23 +81,23 @@ Otherwise please upgrade to GHES version >= 3.5 and If you are also using Github
} }
export function getInputS3ClientConfig(): S3ClientConfig | undefined { export function getInputS3ClientConfig(): S3ClientConfig | undefined {
const s3BucketName = core.getInput(Inputs.AWSS3Bucket) const s3BucketName = core.getInput(Inputs.AWSS3Bucket);
if (!s3BucketName) { if (!s3BucketName) {
return undefined return undefined;
} }
const s3config = { const s3config = {
credentials: { credentials: {
accessKeyId: core.getInput(Inputs.AWSAccessKeyId), accessKeyId: core.getInput(Inputs.AWSAccessKeyId),
secretAccessKey: core.getInput(Inputs.AWSSecretAccessKey) secretAccessKey: core.getInput(Inputs.AWSSecretAccessKey)
}, },
region: core.getInput(Inputs.AWSRegion), region: core.getInput(Inputs.AWSRegion),
endpoint: core.getInput(Inputs.AWSEndpoint), endpoint: core.getInput(Inputs.AWSEndpoint),
bucketEndpoint: core.getBooleanInput(Inputs.AWSS3BucketEndpoint), bucketEndpoint: core.getBooleanInput(Inputs.AWSS3BucketEndpoint),
forcePathStyle: core.getBooleanInput(Inputs.AWSS3ForcePathStyle), forcePathStyle: core.getBooleanInput(Inputs.AWSS3ForcePathStyle)
} as S3ClientConfig } as S3ClientConfig;
core.debug('Enable S3 backend mode.') core.debug("Enable S3 backend mode.");
return s3config return s3config;
} }