diff --git a/doppler.js b/doppler.js index 937779a..70e1757 100644 --- a/doppler.js +++ b/doppler.js @@ -6,7 +6,7 @@ import { VERSION } from "./meta.js"; * @param {string} dopplerToken * @param {string | null} [dopplerProject] * @param {string | null} [dopplerConfig] - * @returns {() => Promise>} + * @returns {() => Promise>} */ async function fetch(dopplerToken, dopplerProject, dopplerConfig) { return new Promise(function (resolve, reject) { @@ -14,7 +14,7 @@ async function fetch(dopplerToken, dopplerProject, dopplerConfig) { const authHeader = `Basic ${encodedAuthData}`; const userAgent = `secrets-fetch-github-action/${VERSION}`; - const url = new URL("https://api.doppler.com/v3/configs/config/secrets/download?format=json"); + const url = new URL("https://api.doppler.com/v3/configs/config/secrets"); if (dopplerProject && dopplerConfig) { url.searchParams.append("project", dopplerProject); url.searchParams.append("config", dopplerConfig); @@ -27,6 +27,7 @@ async function fetch(dopplerToken, dopplerProject, dopplerConfig) { headers: { Authorization: authHeader, "user-agent": userAgent, + "accepts": "application/json", }, }, (res) => { @@ -34,7 +35,7 @@ async function fetch(dopplerToken, dopplerProject, dopplerConfig) { res.on("data", (data) => (payload += data)); res.on("end", () => { if (res.statusCode === 200) { - resolve(JSON.parse(payload)); + resolve(JSON.parse(payload).secrets); } else { try { const error = JSON.parse(payload).messages.join(" "); diff --git a/index.js b/index.js index af8cabb..99d1c86 100644 --- a/index.js +++ b/index.js @@ -27,9 +27,11 @@ if (IS_SA_TOKEN && !(DOPPLER_PROJECT && DOPPLER_CONFIG)) { const secrets = await fetch(DOPPLER_TOKEN, DOPPLER_PROJECT, DOPPLER_CONFIG); -for (const [key, value] of Object.entries(secrets)) { +for (const [key, secret] of Object.entries(secrets)) { + const value = secret.computed || ""; + core.setOutput(key, value); - if (!DOPPLER_META.includes(key)) { + if (!DOPPLER_META.includes(key) && secret.computedVisibility !== "unmasked") { core.setSecret(value); }