I am hoping to achieve to update firebase functions config (env variables) programatically other than manually typing firebase functions:config:set I want to automate this process depending on the returned value from a post call inside the function and possibly invoke cloud run to achieve this.
I've tried below but only worked in local env.
const { exec } = require("child_process");
exports = module.exports = functions.https.onRequest(async (req, res) => {
try {
exec(`firebase functions:config:set hello.world="hhh"`, (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
});
res.status(200).send({ message: 'success' });
}
catch (e) {
console.log('e :>> ', e);
res.status(400).send({ status: res.statusCode, message: 'aborted' });
}
})
If there's a way to achieve this, I'd like to know.
Also wondering if there's way to achieve this with cloud run.
Thank you.