workflows/docker: use GitHub Packages for caching.

The GitHub Actions caching seems to not be very performant and is
exploding our cache storage usage.
This commit is contained in:
Mike McQuaid 2024-11-15 16:14:48 +00:00
parent cd8f476ffe
commit fb03a29ec6
No known key found for this signature in database

View File

@ -12,6 +12,7 @@ on:
permissions: permissions:
contents: read contents: read
packages: write
defaults: defaults:
run: run:
@ -102,21 +103,27 @@ jobs:
fi fi
} | tee -a "${GITHUB_OUTPUT}" } | tee -a "${GITHUB_OUTPUT}"
- name: Log in to GitHub Packages
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
registry: ghcr.io
username: github-actions[bot]
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker image - name: Build Docker image
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6 uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6
with: with:
context: . context: .
load: true load: true
tags: brew tags: brew
cache-from: type=gha cache-from: type=registry,ref=ghcr.io/homebrew/ubuntu${{ matrix.version }}:cache
cache-to: type=gha,mode=max
build-args: version=${{ matrix.version }} build-args: version=${{ matrix.version }}
labels: ${{ steps.attributes.outputs.labels }} labels: ${{ steps.attributes.outputs.labels }}
- name: Run brew test-bot --only-setup - name: Run brew test-bot --only-setup
run: docker run --rm brew brew test-bot --only-setup run: docker run --rm brew brew test-bot --only-setup
- name: Log in to GitHub Packages - name: Log in to GitHub Packages (again)
if: steps.attributes.outputs.push == 'true' if: steps.attributes.outputs.push == 'true'
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3 uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with: with:
@ -138,7 +145,7 @@ jobs:
context: . context: .
push: true push: true
tags: ${{ steps.attributes.outputs.tags }} tags: ${{ steps.attributes.outputs.tags }}
cache-from: type=gha cache-from: type=registry,ref=ghcr.io/homebrew/ubuntu${{ matrix.version }}:cache
cache-to: type=gha,mode=max cache-to: type=registry,ref=ghcr.io/homebrew/ubuntu${{ matrix.version }}:cache,mode=max
build-args: version=${{ matrix.version }} build-args: version=${{ matrix.version }}
labels: ${{ steps.attributes.outputs.labels }} labels: ${{ steps.attributes.outputs.labels }}