Skip to content

Cache

Cache #18

Workflow file for this run

name: Cache
on:
workflow_dispatch:
inputs:
invalidate_cache_1:
default: false
type: boolean
invalidate_cache_2:
default: true
type: boolean
jobs:
upload-cache:
name: upload ${{ matrix.provider }} ${{ matrix.runs-on }}
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
runs-on: [ubuntu-latest, ubicloud]
provider: [gha, minio]
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: enescakir/benchmarking
tags: type=raw,value=large-image-${{ matrix.runs-on }}
- name: Log in to registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Free up space
run: |
docker system prune -f
docker builder prune -f
- name: Invalidate cache 1
if: inputs.invalidate_cache_1
run: touch test1.txt
- name: Invalidate cache 2
if: inputs.invalidate_cache_2
run: touch test2.txt
- name: Build and push cache to GHA
if: matrix.provider == 'gha'
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.cache
platforms: linux/amd64
push: false
# cache-from: type=gha,scope=ubicloud-${{ matrix.runs-on }}
cache-to: type=gha,mode=max,scope=ubicloud-${{ matrix.runs-on }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Build and push cache to MinIO
if: matrix.provider == 'minio'
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.cache
platforms: linux/amd64
push: false
# cache-from: type=s3,region=us-east-1,bucket=ubicloud-cache,name=ubicloud-${{ matrix.runs-on }},use_path_style=true,endpoint_url=${{ secrets.MINIO_ENDPOINT }},access_key_id=${{ secrets.MINIO_USERNAME }},secret_access_key=${{ secrets.MINIO_TOKEN }}
cache-to: type=s3,region=us-east-1,bucket=ubicloud-cache,name=ubicloud-${{ matrix.runs-on }},mode=max,use_path_style=true,endpoint_url=${{ secrets.MINIO_ENDPOINT }},access_key_id=${{ secrets.MINIO_USERNAME }},secret_access_key=${{ secrets.MINIO_TOKEN }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}