Spaces:
Paused
Paused
changed
Browse files
up.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
| 1 |
require('dotenv/config')
|
| 2 |
const { exec } = require('child_process');
|
| 3 |
-
|
| 4 |
-
const { promisify } = require('util')
|
| 5 |
|
| 6 |
const execPromise = promisify(exec);
|
| 7 |
|
| 8 |
const execute = (command) => {
|
| 9 |
return execPromise(command).then(({ stdout, stderr }) => {
|
| 10 |
-
if (stderr) {
|
| 11 |
console.warn(`Stderr: ${stderr}`);
|
| 12 |
}
|
| 13 |
return stdout;
|
|
@@ -18,21 +17,20 @@ const execute = (command) => {
|
|
| 18 |
|
| 19 |
const push = async (username) => {
|
| 20 |
try {
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
| 25 |
-
console.log(
|
| 26 |
-
console.log(await execute('git status'));
|
| 27 |
-
console.log(await execute(`git commit --allow-empty -m "changed"`));
|
| 28 |
-
console.log(await execute('git branch -M main'));
|
| 29 |
-
console.log(await execute(`git push https://${username}:${token}@${repoUrl} main --force`));
|
| 30 |
-
console.log('Commands executed successfully');
|
| 31 |
-
return
|
| 32 |
} catch (error) {
|
| 33 |
-
console.error(`Failed to
|
| 34 |
}
|
| 35 |
};
|
| 36 |
|
| 37 |
-
push("termai")
|
| 38 |
-
.then(()=> process.exit())
|
|
|
|
| 1 |
require('dotenv/config')
|
| 2 |
const { exec } = require('child_process');
|
| 3 |
+
const { promisify } = require('util');
|
|
|
|
| 4 |
|
| 5 |
const execPromise = promisify(exec);
|
| 6 |
|
| 7 |
const execute = (command) => {
|
| 8 |
return execPromise(command).then(({ stdout, stderr }) => {
|
| 9 |
+
if (stderr && !stderr.includes('nothing to commit')) {
|
| 10 |
console.warn(`Stderr: ${stderr}`);
|
| 11 |
}
|
| 12 |
return stdout;
|
|
|
|
| 17 |
|
| 18 |
const push = async (username) => {
|
| 19 |
try {
|
| 20 |
+
const token = process.env.TOKEN;
|
| 21 |
+
const repo = process.env.REPO_NAME;
|
| 22 |
+
const repoUrl = `https://huggingface.co/spaces/${username}/${repo}`;
|
| 23 |
+
const remoteUrl = `https://${username}:${token}@huggingface.co/spaces/${username}/${repo}`;
|
| 24 |
+
|
| 25 |
+
await execute('git config --global --add safe.directory "$(pwd)"');
|
| 26 |
+
|
| 27 |
+
await execute('git commit --allow-empty -m "trigger rebuild"');
|
| 28 |
|
| 29 |
+
await execute(`git push ${remoteUrl} main`);
|
| 30 |
+
console.log('✅ Rebuild triggered via empty commit.');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
} catch (error) {
|
| 32 |
+
console.error(`❌ Failed to push: ${error.message}`);
|
| 33 |
}
|
| 34 |
};
|
| 35 |
|
| 36 |
+
push("termai").then(() => process.exit());
|
|
|