Skip to content

Commit

Permalink
CI: use sha checkout for docker build (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
kingster authored Sep 6, 2022
1 parent 7360d4a commit 514070a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit 514070a

Please sign in to comment.