I have a bitbucket repo which uses bitbucket-pipelines to deploy to a local repository on azure (for our development server). I am working on the build step that the pipelines will use before it deploys to azure. The only thing my build step does right now is output built files into a given directory which is gitignored. It then force adds the gitignored build folder. It then amends to the commit that triggered the pipeline, and finally force pushes the commit to master.
So my file looks something like this
# bitbucket decided to make the repository shallow this line
# makes the repo unshallow so we can push later
- git fetch https://<bitbucket-repo> --unshallow
# doing some setup so we can run the build scripts
- npm install
- npm install -g gulp
# just building files for now we can add tests in later
- npm run build:single
# forcing the build files to be included in the commit
# so that azure has access to the files.
- git add --force public/build/
# do some git configuration so it will let us commit
- git config --global user.email $GIT_USER_EMAIL
- git config --global user.name "\$GIT_USER_NAME"
# add to the last commit so we can keep its message
# this is so we can see the last commit message that was
# done on azure without creating a new commit message
# this command edits the previous commit and should
# never be done when that commit has already been
# pushed to your target branch and if your target branch is
# public.
- git commit --amend --no-edit
# the below line pushes to a branch on azure we setup as a local branch
- git push --force https://<azure-branch-repo> master
My question is:
Am I going to break anything with this git workflow? And are there any suggestions that you have?
I'm figuring that only my pipelines script will push to azure's local repo so it's okay to amend the commit which would otherwise probably be a bad idea if someone else pushes to it. Is this something I should be concerned about? I would like to keep the original commit message as azure displays it in the list of previous deploys. If they all have deploy names correlated with their bitbucket commits it makes it much simpler to go back to a certain deployment.
I was also wondering if this was an okay time to use git push --force
as I hear the --force
flag is considered dangerous. Since I am committing the build files to git for each deployment I will have a commit that strays away from the repo with all the build files in it. My thought was using --force
would forget the last stray commit and just have everything the way bitbucket-pipelines built it. I'm not sure if my interpretation of --force push
is correct.