Skip to content

Commit

Permalink
modify: add cache buster to GitHub action work flow, allows downloadi…
Browse files Browse the repository at this point in the history
…ng fresh source code while building images using cache

resolves #26
  • Loading branch information
Mohammad Mahdi Baghbani Pourvahid committed Dec 19, 2022
1 parent bd96984 commit 5454a59
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/docker-ghcr-branches.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,19 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%dZ:%H:%M:%S')"

- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: ./cyb-app/docker
build-args: |
CACHE_BUSTER=${{ steps.date.outputs.date }}
BUILD_BRANCH=${{ steps.extract_branch.outputs.branch }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
7 changes: 7 additions & 0 deletions .github/workflows/docker-ghcr-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,19 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%dZ:%H:%M:%S')"

- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: ./cyb-app/docker
build-args: |
CACHE_BUSTER=${{ steps.date.outputs.date }}
BUILD_BRANCH=${{ steps.extract_branch.outputs.branch }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
4 changes: 4 additions & 0 deletions cyb-app/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ RUN chmod +x /usr/local/bin/entrypoint.sh

ARG BUILD_REPO="https://github.com/pondersource/CYB/archive/refs/heads"
ARG BUILD_BRANCH="main"

# use cache buster to force download source code.
ARG CACHE_BUSTER
RUN echo "command with external dependencies, cache buster value is ${CACHE_BUSTER}"
ARG DOWNLOAD_LOCATION="${BUILD_REPO}/${BUILD_BRANCH}.zip"

# get cyb project from git repository.
Expand Down

0 comments on commit 5454a59

Please sign in to comment.