Skip to content

🎥 Make videos programmatically with React

fix default creds

Alex Fernandezae96b45453b3
diff --git a/packages/cloudrun/package.json b/packages/cloudrun/package.json
index 512e448c0e..0658693fdd 100644
--- a/packages/cloudrun/package.json
+++ b/packages/cloudrun/package.json
@@ -10,7 +10,8 @@
"watch": "tsc -w",
"lint": "eslint src --ext ts,tsx",
"test": "vitest --run",
- "publish": "cd container && ARTIFACT_REGISTRY_ENV=production node submit.mjs"
+ "publish": "cd container && ARTIFACT_REGISTRY_ENV=production node submit.mjs",
+ "render-cloud": "ts-node src/render-cloud.ts"
},
"dependencies": {
"@google-cloud/artifact-registry": "^2.2.2",
diff --git a/packages/cloudrun/src/api/helpers/get-cloud-run-client.ts b/packages/cloudrun/src/api/helpers/get-cloud-run-client.ts
index e497436218..05bdda504d 100644
--- a/packages/cloudrun/src/api/helpers/get-cloud-run-client.ts
+++ b/packages/cloudrun/src/api/helpers/get-cloud-run-client.ts
@@ -3,11 +3,19 @@ import {v2} from '@google-cloud/run';
const {ServicesClient} = v2;
export const getCloudRunClient = () => {
- return new ServicesClient({
- projectId: process.env.REMOTION_GCP_PROJECT_ID,
- credentials: {
- client_email: process.env.REMOTION_GCP_CLIENT_EMAIL,
- private_key: process.env.REMOTION_GCP_PRIVATE_KEY,
- },
- });
+ if (
+ process.env.REMOTION_GCP_PROJECT_ID &&
+ process.env.REMOTION_GCP_CLIENT_EMAIL &&
+ process.env.REMOTION_GCP_PRIVATE_KEY
+ ) {
+ return new ServicesClient({
+ projectId: process.env.REMOTION_GCP_PROJECT_ID,
+ credentials: {
+ client_email: process.env.REMOTION_GCP_CLIENT_EMAIL,
+ private_key: process.env.REMOTION_GCP_PRIVATE_KEY,
+ },
+ });
+ }
+
+ return new ServicesClient();
};
diff --git a/packages/cloudrun/src/render-cloud.ts b/packages/cloudrun/src/render-cloud.ts
new file mode 100644
index 0000000000..2a942738b8
--- /dev/null
+++ b/packages/cloudrun/src/render-cloud.ts
@@ -0,0 +1,34 @@
+import dotenv from 'dotenv';
+import type {GcpRegion} from './index';
+import {getServices, renderMediaOnCloudrun} from './index';
+dotenv.config();
+async function execute() {
+ const services = await getServices({
+ region: 'australia-southeast2',
+ compatibleOnly: false,
+ });
+
+ const {serviceName} = services[0];
+ console.log(serviceName);
+
+ const result = await renderMediaOnCloudrun({
+ serviceName,
+ region:
+ (process.env.REGION as GcpRegion) ?? ('asia-southeast2' as GcpRegion),
+ serveUrl: process.env.SERVE_URL ?? '',
+ composition: 'MyComp',
+ inputProps: {},
+ codec: 'h264',
+ });
+ if (result.type === 'success') {
+ console.log(result.bucketName);
+ console.log(result.renderId);
+ }
+}
+
+execute()
+ .then(() => process.exit(0))
+ .catch((err) => {
+ console.error(err);
+ process.exit(1);
+ });