From ceb14e53e894bfe7e040d04fee52a9a61a4008d2 Mon Sep 17 00:00:00 2001 From: realkaranvir <113927390+realkaranvir@users.noreply.github.com> Date: Thu, 5 Dec 2024 09:28:39 -0800 Subject: [PATCH] updated workflow file for docker image --- .github/workflows/docker-image.yml | 54 ++++++++++-------------------- 1 file changed, 17 insertions(+), 37 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index b24a031a4..acdb6a1a3 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -3,63 +3,43 @@ name: Docker Image CI/CD on: push: branches: - - master - pull_request: - branches: - - master - + - karan jobs: push_to_registry: name: Push Docker Image to Docker Hub if: github.event_name == 'push' runs-on: ubuntu-latest steps: - - name: Check Repository + - name: Checkout Repository uses: actions/checkout@v4 - - name: Cache SBT Dependencies - uses: actions/cache@v4 - with: - path: | - ~/.ivy2 - ~/.sbt - key: ${{ runner.os }}-sbt-${{ hashFiles('**/Build.sbt') }} - restore-keys: | - ${{ runner.os }}-sbt- - - name: Login to Docker Registry uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_HUB_EMAIL }} password: ${{ secrets.DOCKER_HUB_PASSWORD }} - - name: Build and Push Docker Image to Registry - uses: docker/build-push-action@v5 - with: - context: . - push: true - tags: teamfemrdev/teamfemr:latest - - build: - name: Build Docker Image on Pull Request - if: github.event_name == 'pull_request' - runs-on: ubuntu-latest - steps: - - name: Check Repository - uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - - name: Cache SBT Dependencies + - name: Cache Docker Dependencies uses: actions/cache@v4 with: - path: | - ~/.ivy2 - ~/.sbt + path: sbt-build-cache key: ${{ runner.os }}-sbt-${{ hashFiles('**/Build.sbt') }} restore-keys: | ${{ runner.os }}-sbt- - - name: Build Docker Image - uses: docker/build-push-action@v5 + - name: Inject sbt-build-cache + uses: reproducible-containers/buildkit-cache-dance@4b2444fec0c0fb9dbf175a96c094720a692ef810 # v2.1.4 + with: + cache-source: sbt-build-cache + + - name: Build and Push Docker Image to Registry + uses: docker/build-push-action@v6 with: context: . - push: false + cache-from: type=gha + cache-to: type=gha,mode=max + push: true + tags: teamfemrdev/teamfemr:latest