diff --git a/action.yml b/action.yml index 3729be7..88d41e7 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,5 @@ name: 'Archive UHK releases' -description: 'Upload specific files to AWS S3' +description: 'Upload specific files to S3-compatible object storage' inputs: FILE_PATTERN: description: File pattern of the upload files @@ -19,6 +19,8 @@ inputs: S3_BUCKET: description: S3 Bucket required: true + S3_ENDPOINT: + description: Optional custom S3 endpoint (e.g. Backblaze B2 https://s3..backblazeb2.com) S3_INDEX_FILE_KEY: description: S3 Key of the json index file that store the extra meta data of each s3 object S3_KEY_PREFIX: diff --git a/lib/utils/get-inputs.js b/lib/utils/get-inputs.js index 280d8ab..d1575ac 100644 --- a/lib/utils/get-inputs.js +++ b/lib/utils/get-inputs.js @@ -10,6 +10,7 @@ import { TEST_GITHUB_REPOSITORY, TEST_GITHUB_SHA } from '../constants.js' * @property {string} s3AccessKey * @property {string} s3AccessKeyId * @property {string} s3Bucket + * @property {string} [s3Endpoint] * @property {string} s3IndexFileKey * @property {string} s3KeyPrefix * @property {string} s3Region @@ -31,6 +32,7 @@ export function getInputs() { s3AccessKey: process.env.S3_ACCESS_KEY, s3AccessKeyId: process.env.S3_ACCESS_KEY_ID, s3Bucket: process.env.S3_BUCKET, + s3Endpoint: process.env.S3_ENDPOINT, s3IndexFileKey: process.env.S3_INDEX_FILE_KEY, s3KeyPrefix: process.env.S3_KEY_PREFIX, s3Region: process.env.S3_REGION, @@ -43,6 +45,7 @@ export function getInputs() { s3AccessKey: core.getInput('S3_ACCESS_KEY', { required: true }), s3AccessKeyId: core.getInput('S3_ACCESS_KEY_ID', { required: true }), s3Bucket: core.getInput('S3_BUCKET', { required: true }), + s3Endpoint: core.getInput('S3_ENDPOINT') || process.env.S3_ENDPOINT, s3IndexFileKey: core.getInput('S3_INDEX_FILE_KEY'), s3KeyPrefix: core.getInput('S3_KEY_PREFIX', { required: true }), s3Region: core.getInput('S3_REGION', { required: true }), diff --git a/lib/utils/get-s3-client.js b/lib/utils/get-s3-client.js index 77713fb..7f05500 100644 --- a/lib/utils/get-s3-client.js +++ b/lib/utils/get-s3-client.js @@ -1,5 +1,4 @@ import { S3 } from '@aws-sdk/client-s3' -import process from 'node:process' /** * @param {Inputs} inputs @@ -16,8 +15,8 @@ export function getS3Client(inputs) { region: inputs.s3Region, } - if (process.env.S3_ENDPOINT) { - options.endpoint = process.env.S3_ENDPOINT + if (inputs.s3Endpoint) { + options.endpoint = inputs.s3Endpoint options.forcePathStyle = true }