Created
August 3, 2023 10:25
-
-
Save Xetera/7ae9c61a410d5e9a03244b0636cf1cd9 to your computer and use it in GitHub Desktop.
Mask sensitive values in an entire json file in github actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const file = await import(process.argv[2], { assert: { type: "json" } }) | |
function getValues(obj) { | |
const values = [] | |
if (typeof obj !== "object") { | |
return values | |
} | |
for (const key of Object.keys(obj)) { | |
if (typeof obj[key] === "object") { | |
values.push(...getValues(obj[key])) | |
} else if (typeof obj[key] !== "boolean") { | |
values.push(obj[key]) | |
} | |
} | |
return values | |
} | |
const values = getValues(file) | |
for (const value of values) { | |
console.log(`::add-mask::${value}`) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment