diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 8d4c8f30..4bc50a26 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -46,6 +46,19 @@ jobs: key: ${{ runner.os }}-buildx-docker-${{ github.sha }} restore-keys: | ${{ runner.os }}-buildx-docker- + - name: Extract Commit SHA + id: sha_extract + run: | + if [ $IS_PR == 'pull_request' ] + then + echo "::set-output name=sha::$PR_REF" + else + echo "::set-output name=sha::$BRANCH_REF" + fi + env: + IS_PR: ${{ github.event_name }} + BRANCH_REF: ${{ github.ref }} + PR_REF: ${{ github.event.pull_request.head.sha }} - name: Build Docker Image uses: docker/build-push-action@v3 with: @@ -59,6 +72,7 @@ jobs: cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max build-args: | BASE=ubuntu:20.04 + GIT_SHA=${{ steps.sha_extract.outputs.sha }} - name: Move cache run: | rm -rf /tmp/.buildx-cache diff --git a/Dockerfile b/Dockerfile index 3a0df03f..aeacd027 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,8 +31,9 @@ ENV PATH="/usr/local/go/bin:${PATH}" # Install DKV (Skipped for CI Pipelines) ARG CI -RUN if [ -z "$CI" ] ; then git clone --depth=1 https://github.com/flipkart-incubator/dkv.git \ - && cd dkv && GOOS=linux GOARCH=$(dpkg --print-architecture) make build \ +ARG GIT_SHA=master +RUN if [ -z "$CI" ] ; then git clone https://github.com/flipkart-incubator/dkv.git \ + && cd dkv && git checkout $GIT_SHA && GOOS=linux GOARCH=$(dpkg --print-architecture) make build \ && mv ./bin /usr/local/dkv && chown -R root:root /usr/local/dkv; fi ENV PATH="/usr/local/dkv:${PATH}"