Adding New Journal Causing Failed Deployment to Vercel in Astro JS with Pagefind

Tags: Astro JS, Vercel, DevOps

Context or Problem

Damn, I just want to relax and preview the new site that automatically deployed to vercel but instead I got email of failed deployment. It’s all because I forgot to run npm run build{:sh} to re-update may Astro JS /dist folder so that Pagefind can run after that.

I don’t know how to let it’s all done in Vercel or Github Actions. For now the only way come to my mind is just prevent git push{:sh} if I have not build this project for production. Then as an average human, I ask Copilot and it said to use Husky which I remember mentioned somewhere in React JS discussion on my old days.

I make some fast research maybe yeah Husky is the good fit for it while I also keep an eye on other one like Lefthook which is based on Go.

I will try it now.

Experiment

To get started the docs said to install Husky as dev dependency.

npm install --save-dev husky{:sh}

They recommend to run init

npx husky init{:sh}

and now I have /.husky folder with some I believe it’s default file and one sample file for pre-commit which is really what I looking for.

Then I fill that file with npm run build && npm run postbuild{:sh} in hope it will triggered on each future commit hehe.

Some minutes later…

I have commit the above article and the commit takes a bit long than usual which I believe husky is running there. Well I will leave it for now and commit again for this text and see if I push to GitHub will it be failed again or not.

Outcome

Kinda works!

Possible Next Steps

References