Task: I want to use a Bitbucket pipeline to deploy a Jekyll site to Heroku without adding the _site
folder generated by local Jekyll builds.
Possible Solution: Below are my pipeline commands for building a Jekyll _site
folder in the Docker container, modifying the git index, and pushing to Heroku. The build passes and deploys correctly to Heroku.
script:
- bundle install --path vendor/bundle
- npm install -g gulp
- gulp preview
- git config --global user.email $EMAIL
- git config --global user.name $USER
- git rm . -r --cached
- git add -f Procfile index.js _site package.json
- git commit -m "Eliminate all but site"
- git push -f https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git HEAD
Remaining Concerns: I'm removing all of the files from the index except for the files that Heroku needs to deploy. I'm also forcing git add
and git push
which are generally discouraged (1, 2). Fyi, git push --force-with-lease
fails w/ ! [rejected] HEAD -> master (stale info)
I've been working on this for a few days and haven't found any references to the above uses of git --force
commands with Bitbucket pipelines and Heroku. But since Bitbucket pipeline commands are performed within a Docker container with a cloned repo, the idiosyncratic usage shouldn't matter, right? It's okay to git --force
changes bc these changes are entirely separate from local copies and the Bitbucket repo. The usual concerns about overwriting local changes and history w/ force don't apply.
I've only been working with Bitbucket pipelines, Jekyll, and Docker for a few weeks, so I just want to make sure I'm covering my bases. Thanks for any help!