Skip to content

Instantly share code, notes, and snippets.

@Xetera
Created August 3, 2023 10:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xetera/7ae9c61a410d5e9a03244b0636cf1cd9 to your computer and use it in GitHub Desktop.
Save Xetera/7ae9c61a410d5e9a03244b0636cf1cd9 to your computer and use it in GitHub Desktop.
Mask sensitive values in an entire json file in github actions
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