Skip to content

Commit

Permalink
type check in YAML mapSecrets
Browse files Browse the repository at this point in the history
  • Loading branch information
TimeTravelerFromNow committed Sep 19, 2024
1 parent 2142db0 commit 94abcbc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/context/yaml/handlers/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ async function parse(context: YAMLContext): Promise<ParsedActions> {
};
}

function mapSecrets(secrets: { name: string; value: string }[]): Secret[] {
function mapSecrets(secrets) {
if (typeof secrets === 'string') {
return secrets; //Enables keyword preservation to operate on action secrets
}
if (secrets && secrets.length > 0) {
return secrets.map((secret) => ({ name: secret.name, value: secret.value }));
}
Expand Down Expand Up @@ -86,8 +89,7 @@ async function dump(context: YAMLContext): Promise<ParsedActions> {
runtime: action.runtime,
dependencies: action.dependencies || [],
status: action.status,
secrets:
typeof action.secrets === 'string' ? action.secrets : mapSecrets(action.secrets || []), //Enables keyword preservation to operate on action secrets
secrets: mapSecrets(action.secrets),
supported_triggers: action.supported_triggers,
})),
};
Expand Down

0 comments on commit 94abcbc

Please sign in to comment.