From a858ae01dfd5ebd7b24de36ba833709f5a91e4af Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Fri, 28 Apr 2023 19:03:56 +0200 Subject: [PATCH] build(github): Enable Docker image caching between workflows For details see [1]. [1]: https://docs.docker.com/build/ci/github-actions/cache/#github-cache Signed-off-by: Sebastian Schuberth --- .github/workflows/build-and-test.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index f2808fd1ba003..aeca9c1a37773 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -148,6 +148,33 @@ jobs: java-version: 17 - name: Restore Gradle cache entries uses: gradle/gradle-build-action@v2 + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push the Docker image + uses: docker/build-push-action@v4 + with: + build-args: USER_ID=1001 + context: . + cache-from: type=registry,ref=ort:buildcache + cache-to: type=registry,ref=ort:buildcache,mode=max + push: true + tags: ort:pr + - name: Build and load the Docker image + uses: docker/build-push-action@v4 + with: + build-args: USER_ID=1001 + context: . + cache-from: type=registry,ref=ort:buildcache + cache-to: type=registry,ref=ort:buildcache,mode=max + load: true + - name: Build Docker image manually + run: DOCKER_BUILDKIT=1 docker build --build-arg USER_ID=1001 . - name: Validate Batect wrapper scripts uses: batect/batect-wrapper-validation-action@v0 - name: Run functional tests that do require external tools