Use json for input to custom-tags, add documentation for custom-tags

This commit is contained in:
Sylvain Verly 2025-03-20 15:41:20 +01:00 committed by Tom Keller
commit ba1ab7fb3b
3 changed files with 8 additions and 6 deletions

View file

@ -1,4 +1,3 @@
name: '"Configure AWS Credentials" Action for GitHub Actions'
description: Configures AWS credentials for use in subsequent steps in a GitHub Action workflow
runs:
@ -101,6 +100,12 @@ inputs:
action-timeout-s:
required: false
description: A global timeout in seconds for the action. When the timeout is reached, the action immediately exits. The default is to run without a timeout.
custom-tags:
description: >-
Additional tags to apply to the assumed role session. Must be a JSON object provided using toJSON.
Example: custom-tags: ${{ toJSON({ Environment: 'Production', Team: 'DevOps' }) }}
You can include secrets: custom-tags: ${{ toJSON({ Team: secrets.TEAM_NAME }) }}
required: false
outputs:
aws-account-id:

View file

@ -45,10 +45,7 @@ export async function run() {
const proxyServer = core.getInput('http-proxy', { required: false }) || process.env.HTTP_PROXY;
const customTagsInput = core.getInput('custom-tags', { required: false });
const customTags = customTagsInput
? (typeof customTagsInput === 'string' && customTagsInput.trim().startsWith('{')
? Object.entries(JSON.parse(customTagsInput))
: Object.entries(customTagsInput)
).map(([Key, Value]) => ({ Key, Value: String(Value) }))
? Object.entries(JSON.parse(customTagsInput)).map(([Key, Value]) => ({ Key, Value: String(Value) }))
: [];
const inlineSessionPolicy = core.getInput('inline-session-policy', { required: false });
const managedSessionPolicies = core.getMultilineInput('managed-session-policies', { required: false }).map((p) => {

View file

@ -18,7 +18,7 @@ const inputs = {
'aws-secret-access-key': 'MYAWSSECRETACCESSKEY',
'role-to-assume': 'arn:aws:iam::111111111111:role/MY-ROLE',
'aws-region': 'fake-region-1',
'custom-tags': { Environment: 'Production', Team: 'DevOps' },
'custom-tags': JSON.stringify({ Environment: 'Production', Team: 'DevOps' }),
},
IAM_USER_INPUTS: {
'aws-access-key-id': 'MYAWSACCESSKEYID',