From 977ceaeeb648b53f84c970609e861a2b6ff3ea6c 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..1dbc5f79bb6b0 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: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v2 + - 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