Skip to content

Commit 2c168ad

Browse files
kellertklehmanmj
andauthored
feat: support action inputs as environment variables (#1338)
* support action inputs as environment variables * update dist * fix: update tsconfig for package step * fix: update environment variable setting method * fix: make biome happy --------- Co-authored-by: Michael Lehmann <lehmanmj@amazon.com>
1 parent 4d5f239 commit 2c168ad

19 files changed

+100
-197
lines changed

dist/cleanup/CredentialsClient.d.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

dist/cleanup/assumeRole.d.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

dist/cleanup/cleanup/index.d.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/cleanup/helpers.d.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

dist/cleanup/index.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/cleanup/index.js

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/cleanup/src/CredentialsClient.d.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

dist/cleanup/src/assumeRole.d.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

dist/cleanup/src/cleanup/index.d.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

dist/cleanup/src/helpers.d.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

dist/cleanup/src/index.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/cleanup/test/cleanup.test.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/cleanup/test/helpers.test.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/cleanup/test/index.test.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/cleanup/test/mockinputs.test.d.ts

Lines changed: 0 additions & 74 deletions
This file was deleted.

dist/index.js

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/helpers.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,38 @@ const MAX_TAG_VALUE_LENGTH = 256;
77
const SANITIZATION_CHARACTER = '_';
88
const SPECIAL_CHARS_REGEX = /[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]+/;
99

10+
export function translateEnvVariables() {
11+
const envVars = [
12+
'AWS_REGION',
13+
'ROLE_TO_ASSUME',
14+
'AWS_ACCESS_KEY_ID',
15+
'AWS_SECRET_ACCESS_KEY',
16+
'AWS_SESSION_TOKEN',
17+
'WEB_IDENTITY_TOKEN_FILE',
18+
'ROLE_CHAINING',
19+
'AUDIENCE',
20+
'HTTP_PROXY',
21+
'MASK_AWS_ACCOUNT_ID',
22+
'ROLE_DURATION_SECONDS',
23+
'ROLE_EXTERNAL_ID',
24+
'ROLE_SESSION_NAME',
25+
'ROLE_SKIP_SESSION_TAGGING',
26+
'INLINE_SESSION_POLICY',
27+
'MANAGED_SESSION_POLICIES',
28+
'OUTPUT_CREDENTIALS',
29+
'UNSET_CURRENT_CREDENTIALS',
30+
'DISABLE_RETRY',
31+
'RETRY_MAX_ATTEMPTS',
32+
'SPECIAL_CHARACTERS_WORKAROUND',
33+
'USE_EXISTING_CREDENTIALS',
34+
];
35+
for (const envVar of envVars) {
36+
if (process.env[envVar]) {
37+
process.env[`INPUT_${envVar.replace(/_/g, '-')}`] = process.env[envVar];
38+
}
39+
}
40+
}
41+
1042
// Configure the AWS CLI and AWS SDKs using environment variables and set them as secrets.
1143
// Setting the credentials as secrets masks them in Github Actions logs
1244
export function exportCredentials(creds?: Partial<Credentials>, outputCredentials?: boolean) {

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
exportCredentials,
1010
exportRegion,
1111
retryAndBackoff,
12+
translateEnvVariables,
1213
unsetCredentials,
1314
verifyKeys,
1415
} from './helpers';
@@ -19,6 +20,7 @@ const REGION_REGEX = /^[a-z0-9-]+$/g;
1920

2021
export async function run() {
2122
try {
23+
translateEnvVariables();
2224
// Get inputs
2325
const AccessKeyId = core.getInput('aws-access-key-id', { required: false });
2426
const SecretAccessKey = core.getInput('aws-secret-access-key', {

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"module": "CommonJS",
1414
"resolveJsonModule": true,
1515
"outDir": "build",
16-
"declaration": true,
16+
"declaration": false,
1717
"newLine": "lf",
1818
"noEmitOnError": true,
1919
"sourceMap": true,

0 commit comments

Comments
 (0)