save git hash to file during prepare step
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
Joseph Montanaro 2020-12-29 20:25:56 -08:00
parent abc3c4d752
commit ccd779e931

View File

@ -68,6 +68,7 @@ steps:
- cd drone - cd drone
- LATEST_VERSION=$(git tag --sort v:refname | grep '^v[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}$' | tail -n 1) - LATEST_VERSION=$(git tag --sort v:refname | grep '^v[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}$' | tail -n 1)
- git checkout $LATEST_VERSION - git checkout $LATEST_VERSION
- printf $(git log -n 1 --pretty=%H) > ../commit_hash # we'll need this for the docker build
- GOLANG_IMG=$(yq read .drone.yml 'steps[0].image') - GOLANG_IMG=$(yq read .drone.yml 'steps[0].image')
- docker pull $GOLANG_IMG - docker pull $GOLANG_IMG
- docker tag $GOLANG_IMG drone-builder:latest - docker tag $GOLANG_IMG drone-builder:latest
@ -95,12 +96,11 @@ steps:
commands: commands:
- cd drone - cd drone
- rm .dockerignore - rm .dockerignore
- COMMIT_HASH=$(git log -n 1 --pretty=%H)
- > - >
docker build docker build
-f docker/Dockerfile.server.linux.amd64 -f docker/Dockerfile.server.linux.amd64
-t registry.jfmonty2.com/drone-server:latest -t registry.jfmonty2.com/drone-server:latest
--label drone_commit_hash=$COMMIT_HASH --label drone_commit_hash=$(cat ../commit_hash)
. .
- name: deploy - name: deploy