79164157

Date: 2024-11-06 20:28:31
Score: 0.5
Natty:
Report link

In the end I wrote a js script in another file.

const ghpages = require('gh-pages');
const { execSync } = require('child_process');

try {
    const commitHash = execSync('git rev-parse HEAD').toString().trim();
    ghpages.publish('build', {
        dotfiles: true,
        message: `Deploying commit ${commitHash}`
    }, (err) => {
        if (err) console.error('Deployment error:', err);
        else console.log('Deployed successfully');
    });
} catch (error) {
    console.error('Error fetching commit hash:', error);
}

Called from package.json with:

"deploy": "node scripts/deploy.cjs"
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: KauĂȘ Rodrigues