Skip to content

Added cache for GHA Docker builds #1502

Added cache for GHA Docker builds

Added cache for GHA Docker builds #1502

name: Docker test build
on:
pull_request:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
build-image:
runs-on: ubuntu-latest
strategy:
matrix:
req_file:
- prod.txt
- tests.txt
# steps taken (and trimmed) from docker-publish.yml
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Test docker image build (local development)
uses: docker/build-push-action@v6
with:
context: .
push: false
build-args: |
REQ_FILE=requirements/${{ matrix.req_file }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-test-build-${{ matrix.req_file }}
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-test-build-${{ matrix.req_file }},mode=max