From 9a90605918fd4c23059ba6d9f55290ac18748148 Mon Sep 17 00:00:00 2001 From: Lucas Mellos Carlos Date: Wed, 20 Dec 2023 11:07:36 -0300 Subject: [PATCH] configure docker caching --- .github/actions/docker/action.yml | 12 ++++++++++-- .github/workflows/ci-build.yml | 13 ++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.github/actions/docker/action.yml b/.github/actions/docker/action.yml index 696f628a..99893420 100644 --- a/.github/actions/docker/action.yml +++ b/.github/actions/docker/action.yml @@ -59,6 +59,14 @@ inputs: default: 'false' description: 'Generate tag only.' required: false + CACHE_FROM: + default: 'type=gha' + description: 'Cache from.' + required: false + CACHE_TO: + default: 'type=gha,mode=max' + description: 'Cache to.' + required: false outputs: IMAGE_TAG: description: "Export image tag" @@ -150,8 +158,8 @@ runs: push: true tags: | ${{ steps.meta.outputs.tags }} - # cache-from: type=gha - # cache-to: type=gha,mode=max + cache-from: ${{ inputs.CACHE_FROM }} + cache-to: ${{ inputs.CACHE_TO }}} file: ${{ inputs.FILE }} context: ${{ inputs.CONTEXT }} platforms: ${{ inputs.PLATFORMS }} diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 08581916..7bd9acbc 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -102,6 +102,16 @@ on: type: string description: ref to pull and build default to github.ref required: false + CACHE_FROM: + type: string + default: 'type=gha' + description: 'Cache from.' + required: false + CACHE_TO: + type: string + default: 'type=gha,mode=max' + description: 'Cache to.' + required: false secrets: DOCKERHUB_USERNAME: required: false @@ -130,7 +140,6 @@ on: BUILD_ARGS: required: false description: Whenever we wanna use secrets and mount them as env - outputs: IMAGE_TAG: value: ${{ jobs.build.outputs.IMAGE_TAG }} @@ -226,6 +235,8 @@ jobs: CONTAINER_TEST: ${{ inputs.CONTAINER_TEST }} CONTAINER_TEST_COMMAND: ${{ inputs.CONTAINER_TEST_COMMAND }} OUTPUT_TAG_INDEX: ${{ inputs.OUTPUT_TAG_INDEX }} + CACHE_FROM: ${{ inputs.CACHE_FROM }} + CACHE_TO: ${{ inputs.CACHE_TO }} env: GITHUB_TOKEN: ${{ github.token }} DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}