Skip to content

Commit 595bca9

Browse files
authored
refactor!: expose keys via env variable (#29)
the access and secret key are now registered as secret and then exposed to s3cmd via the env variables AWS_ACCESS_KEY and AWS_SECRET_KEY. This prevents the need to write them to disk. However, it can happen that this interferes with other values the user needs for these variables. Usually it should be aligned, even if these keys are used for other purposes. Because they operate on the same account. Signed-off-by: Nico Braun <[email protected]>
1 parent 3980454 commit 595bca9

File tree

3 files changed

+50
-136
lines changed

3 files changed

+50
-136
lines changed

dist/index.js

+25-68
Original file line numberDiff line numberDiff line change
@@ -24957,13 +24957,17 @@ module.exports = {
2495724957
const tests = {};
2495824958
exports.tests = tests;
2495924959

24960-
exports.aws = ({ region = "US", access_key = "", secret_key = "" }) => ({
24960+
// each provider function should return an object of keys that should be
24961+
// set in the final s3cmd config file. Any key can be set. not just the
24962+
// ones that are commonly used below.
24963+
// for each provider, one or more tests should be defined in the tests
24964+
// object.
24965+
24966+
exports.aws = ({ region = "US" }) => ({
2496124967
bucket_location: region,
2496224968
host_base: "s3.amazonaws.com",
2496324969
host_bucket: "%(bucket)s.s3.amazonaws.com",
2496424970
website_endpoint: "http://%(bucket)s.s3-website-%(location)s.amazonaws.com/",
24965-
access_key,
24966-
secret_key,
2496724971
});
2496824972

2496924973
tests.aws = {
@@ -24978,17 +24982,11 @@ tests.aws = {
2497824982
],
2497924983
};
2498024984

24981-
exports.digitalocean = ({
24982-
region = "nyc3",
24983-
access_key = "",
24984-
secret_key = "",
24985-
}) => ({
24985+
exports.digitalocean = ({ region = "nyc3" }) => ({
2498624986
bucket_location: region,
2498724987
host_base: `${region}.digitaloceanspaces.com`,
2498824988
host_bucket: `%(bucket)s.${region}.digitaloceanspaces.com`,
2498924989
website_endpoint: `http://%(bucket)s.website-${region}.digitaloceanspaces.com`,
24990-
access_key,
24991-
secret_key,
2499224990
});
2499324991

2499424992
tests.digitalocean = {
@@ -25003,17 +25001,11 @@ tests.digitalocean = {
2500325001
],
2500425002
};
2500525003

25006-
exports.linode = ({
25007-
region = "eu-central-1",
25008-
access_key = "",
25009-
secret_key = "",
25010-
}) => ({
25004+
exports.linode = ({ region = "eu-central-1" }) => ({
2501125005
bucket_location: "US",
2501225006
host_base: `${region}.linodeobjects.com`,
2501325007
host_bucket: `%(bucket)s.${region}.linodeobjects.com`,
2501425008
website_endpoint: `http://%(bucket)s.website-${region}.linodeobjects.com/`,
25015-
access_key,
25016-
secret_key,
2501725009
});
2501825010

2501925011
tests.linode = {
@@ -25028,17 +25020,11 @@ tests.linode = {
2502825020
],
2502925021
};
2503025022

25031-
exports.scaleway = ({
25032-
region = "fr-par",
25033-
access_key = "",
25034-
secret_key = "",
25035-
}) => ({
25023+
exports.scaleway = ({ region = "fr-par" }) => ({
2503625024
bucket_location: region,
2503725025
host_base: `s3.${region}.scw.cloud`,
2503825026
host_bucket: `%(bucket)s.s3.${region}.scw.cloud`,
2503925027
website_endpoint: `https://%(bucket)s.s3-website.${region}.scw.cloud/`,
25040-
access_key,
25041-
secret_key,
2504225028
});
2504325029

2504425030
tests.scaleway = {
@@ -25053,18 +25039,11 @@ tests.scaleway = {
2505325039
],
2505425040
};
2505525041

25056-
exports.cloudflare = ({
25057-
account_id = "",
25058-
region = "auto",
25059-
access_key = "",
25060-
secret_key = "",
25061-
}) => ({
25042+
exports.cloudflare = ({ account_id = "", region = "auto" }) => ({
2506225043
bucket_location: region,
2506325044
host_base: `${account_id}.r2.cloudflarestorage.com`,
2506425045
host_bucket: "",
2506525046
website_endpoint: "",
25066-
access_key,
25067-
secret_key,
2506825047
});
2506925048

2507025049
tests.cloudflare = {
@@ -25080,13 +25059,11 @@ tests.cloudflare = {
2508025059
],
2508125060
};
2508225061

25083-
exports.vultr = ({ region = "ewr1", access_key = "", secret_key = "" }) => ({
25062+
exports.vultr = ({ region = "ewr1" }) => ({
2508425063
bucket_location: region,
2508525064
host_base: `${region}.vultrobjects.com`,
2508625065
host_bucket: `%(bucket)s.${region}.vultrobjects.com`,
2508725066
website_endpoint: "",
25088-
access_key,
25089-
secret_key,
2509025067
});
2509125068

2509225069
tests.vultr = {
@@ -25100,17 +25077,11 @@ tests.vultr = {
2510025077
],
2510125078
};
2510225079

25103-
exports.clevercloud = ({
25104-
region = "US",
25105-
access_key = "",
25106-
secret_key = "",
25107-
}) => ({
25080+
exports.clevercloud = ({ region = "US" }) => ({
2510825081
bucket_location: region,
2510925082
host_base: `cellar-c2.services.clever-cloud.com`,
2511025083
host_bucket: `%(bucket)s.cellar-c2.services.clever-cloud.com`,
2511125084
website_endpoint: "",
25112-
access_key,
25113-
secret_key,
2511425085
});
2511525086

2511625087
tests.clevercloud = {
@@ -25125,13 +25096,11 @@ tests.clevercloud = {
2512525096
],
2512625097
};
2512725098

25128-
exports.hcloud = ({ region = "fsn1", access_key = "", secret_key = "" }) => ({
25099+
exports.hcloud = ({ region = "fsn1" }) => ({
2512925100
bucket_location: region,
2513025101
host_base: `fsn1.your-objectstorage.com`,
2513125102
host_bucket: `%(bucket)s.fsn1.your-objectstorage.com`,
2513225103
website_endpoint: "",
25133-
access_key,
25134-
secret_key,
2513525104
});
2513625105

2513725106
tests.hcloud = {
@@ -25145,17 +25114,11 @@ tests.hcloud = {
2514525114
],
2514625115
};
2514725116

25148-
exports.synologyc2 = ({
25149-
region = "us-001",
25150-
access_key = "",
25151-
secret_key = "",
25152-
}) => ({
25117+
exports.synologyc2 = ({ region = "us-001" }) => ({
2515325118
bucket_location: region,
2515425119
host_base: `${region}.s3.synologyc2.net`,
2515525120
host_bucket: ``,
2515625121
website_endpoint: "",
25157-
access_key,
25158-
secret_key,
2515925122
});
2516025123

2516125124
tests.synologyc2 = {
@@ -25168,17 +25131,11 @@ tests.synologyc2 = {
2516825131
],
2516925132
};
2517025133

25171-
exports.wasabi = ({
25172-
region = "ap-southeast-1",
25173-
access_key = "",
25174-
secret_key = "",
25175-
}) => ({
25134+
exports.wasabi = ({ region = "ap-southeast-1" }) => ({
2517625135
bucket_location: region,
2517725136
host_base: `s3.${region}.wasabisys.com`,
2517825137
host_bucket: `%(bucket)s.s3.${region}.wasabisys.com`,
2517925138
website_endpoint: "",
25180-
access_key,
25181-
secret_key,
2518225139
});
2518325140

2518425141
tests.wasabi = {
@@ -25192,17 +25149,11 @@ tests.wasabi = {
2519225149
],
2519325150
};
2519425151

25195-
exports.yandex = ({
25196-
region = "ru-central1",
25197-
access_key = "",
25198-
secret_key = "",
25199-
}) => ({
25152+
exports.yandex = ({ region = "ru-central1" }) => ({
2520025153
bucket_location: region,
2520125154
host_base: `storage.yandexcloud.net`,
2520225155
host_bucket: `%(bucket)s.storage.yandexcloud.net`,
2520325156
website_endpoint: "",
25204-
access_key,
25205-
secret_key,
2520625157
});
2520725158

2520825159
tests.yandex = {
@@ -27192,12 +27143,18 @@ if (process.env.RUNNER_TEMP) {
2719227143
core.debug(`S3CMD_CONFIG=${process.env.S3CMD_CONFIG}`);
2719327144
}
2719427145

27146+
// expose the access and secret key as github action variables.
27147+
// registering them as secret, just to be sure. normally they should be
27148+
// be registered already. registering leads to masking in logs
27149+
core.setSecret(core.getInput("access_key"));
27150+
core.setSecret(core.getInput("secret_key"));
27151+
core.exportVariable("AWS_ACCESS_KEY", core.getInput("access_key"));
27152+
core.exportVariable("AWS_SECRET_KEY", core.getInput("secret_key"));
27153+
2719527154
configure(
2719627155
providers[core.getInput("provider")]({
2719727156
region: core.getInput("region"),
2719827157
account_id: core.getInput("account_id"),
27199-
access_key: core.getInput("access_key"),
27200-
secret_key: core.getInput("secret_key"),
2720127158
}),
2720227159
);
2720327160

src/index.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,18 @@ if (process.env.RUNNER_TEMP) {
4141
core.debug(`S3CMD_CONFIG=${process.env.S3CMD_CONFIG}`);
4242
}
4343

44+
// expose the access and secret key as github action variables.
45+
// registering them as secret, just to be sure. normally they should be
46+
// be registered already. registering leads to masking in logs
47+
core.setSecret(core.getInput("access_key"));
48+
core.setSecret(core.getInput("secret_key"));
49+
core.exportVariable("AWS_ACCESS_KEY", core.getInput("access_key"));
50+
core.exportVariable("AWS_SECRET_KEY", core.getInput("secret_key"));
51+
4452
configure(
4553
providers[core.getInput("provider")]({
4654
region: core.getInput("region"),
4755
account_id: core.getInput("account_id"),
48-
access_key: core.getInput("access_key"),
49-
secret_key: core.getInput("secret_key"),
5056
}),
5157
);
5258

0 commit comments

Comments
 (0)