I have a project which is deployed on Heroku and I would like to make a public version for Github. The problem is that there is a folder
libs which contains multiple .js files and should be pushed to Heroku, but not Github. Obviously, Heroku CLI config with is not the answer as I have entire files to hide, not just API keys.
So, how can I push the full project to Heroku, but only the partial project to Github? Most of the answers I found talked about the Heroku CLI which cannot apply in my case, because I am trying to hide files, not keys, and another quite hardcore answer was to push first to have a
github branch on which I would
git cherry-pick commits on the heroku branch. I've been using the previous answer so far, but it is quite hard to always repeat this procedure (at least
git checkout github ->
git cherry-pick COMMIT-ID) and kind of messes the history.
So I tried making a post-commit hook so that every time I committed on master (heroku), it would switch to the github branch, cherry-pick the commit then come back to master so that the procedure would look seamless. Unfortunately, this only works sometimes but glitches git more than anything.
branch=`git branch | grep \* | cut -d ' ' -f2` if [ "$branch" ="master" ] then echo "Executing post-commit script (cherry-pick)..." commitID=`git rev-parse HEAD` git checkout Github git cherry-pick $commitID git checkout master echo "Cherry picked $commitID into Github branch" fi
EDIT: Seems like the post-commit hook seems to work most of the time now. I think the problems come when I commit via VSCode, but if I commit through the terminal, it runs cleanly without weird behavior... Still, it would be nice to have a perhaps safer way to do this.