cors / up.js
Rifd's picture
changed
ef41f13
raw
history blame
1.12 kB
require('dotenv/config')
const { exec } = require('child_process');
const { promisify } = require('util');
const execPromise = promisify(exec);
const execute = (command) => {
return execPromise(command).then(({ stdout, stderr }) => {
if (stderr && !stderr.includes('nothing to commit')) {
console.warn(`Stderr: ${stderr}`);
}
return stdout;
}).catch((error) => {
throw new Error(`Error: ${error.message}`);
});
};
const push = async (username) => {
try {
const token = process.env.TOKEN;
const repo = process.env.REPO_NAME;
const repoUrl = `https://huggingface.co/spaces/${username}/${repo}`;
const remoteUrl = `https://${username}:${token}@huggingface.co/spaces/${username}/${repo}`;
await execute('git config --global --add safe.directory "$(pwd)"');
await execute('git commit --allow-empty -m "trigger rebuild"');
await execute(`git push ${remoteUrl} main`);
console.log('✅ Rebuild triggered via empty commit.');
} catch (error) {
console.error(`❌ Failed to push: ${error.message}`);
}
};
push("termai").then(() => process.exit());