mirror of
https://github.com/rowyio/rowy.git
synced 2026-02-24 12:10:18 +01:00
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
// Initialize Firebase Admin
|
|
import * as admin from "firebase-admin";
|
|
// Initialize Firebase Admin
|
|
const serverTimestamp = admin.firestore.FieldValue.serverTimestamp;
|
|
const serviceAccount = requireIfExists(`./firebase-credentials.json`);
|
|
|
|
function requireIfExists(module) {
|
|
try {
|
|
return require(module);
|
|
} catch (error) {
|
|
console.log("serviceAccount json not found");
|
|
return false;
|
|
}
|
|
}
|
|
if (serviceAccount) {
|
|
console.log(`Running on ${serviceAccount.project_id}`);
|
|
admin.initializeApp({
|
|
credential: admin.credential.cert(serviceAccount),
|
|
databaseURL: `https://${serviceAccount.project_id}.firebaseio.com`,
|
|
});
|
|
const db = admin.firestore();
|
|
|
|
const main = async (deployRequestPath: string, currentBuild) => {
|
|
await db.doc(deployRequestPath).update({
|
|
deployedAt: serverTimestamp(),
|
|
currentBuild: currentBuild ?? "",
|
|
});
|
|
return true;
|
|
};
|
|
|
|
main(process.argv[2], process.argv[3])
|
|
.catch((err) => console.log(err))
|
|
.then(() => console.log("this will succeed"))
|
|
.catch(() => "obligatory catch");
|
|
}
|