Skip to content

Make credential export to GitHub env optional #1372

Closed
@gruuya

Description

@gruuya

Describe the feature

Currently the step will always export the credentials to the GitHub env, even when output-credentials is set to true (which exports them as step outputs then too)

export function exportCredentials(creds?: Partial<Credentials>, outputCredentials?: boolean) {
if (creds?.AccessKeyId) {
core.setSecret(creds.AccessKeyId);
core.exportVariable('AWS_ACCESS_KEY_ID', creds.AccessKeyId);
}
if (creds?.SecretAccessKey) {
core.setSecret(creds.SecretAccessKey);
core.exportVariable('AWS_SECRET_ACCESS_KEY', creds.SecretAccessKey);
}
if (creds?.SessionToken) {
core.setSecret(creds.SessionToken);
core.exportVariable('AWS_SESSION_TOKEN', creds.SessionToken);
} else if (process.env.AWS_SESSION_TOKEN) {
// clear session token from previous credentials action
core.exportVariable('AWS_SESSION_TOKEN', '');
}
if (outputCredentials) {
if (creds?.AccessKeyId) {
core.setOutput('aws-access-key-id', creds.AccessKeyId);
}
if (creds?.SecretAccessKey) {
core.setOutput('aws-secret-access-key', creds.SecretAccessKey);
}
if (creds?.SessionToken) {
core.setOutput('aws-session-token', creds.SessionToken);
}
if (creds?.Expiration) {
core.setOutput('aws-expiration', creds.Expiration);
}
}
}

I'd like the GitHub env export to be controllable so as not to "polute" it.

Use Case

A lot of libraries/applications/programs nowadays end up picking up these creds, and I might prefer the obtained credentials to be scoped only to specific steps, or even specific commands within some step. In other words I'd like a more fine-grained/opt-in approach to be available.

Proposed Solution

I see two alternatives

  1. Make output-credentials exclusive: when false export only to env (as now), but when true export only as step output. A renaming of the option might be in order too, since it's not clear what the output refers to.
  2. Replace output-credentials with two new options, e.g. output-step (defaulting to false), and output-env (defaulting to true). This would allow control of all possible combinations of outputs.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/smallThis issue will take less than a day of effort to fixfeature-requestA feature should be added or improved.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions