Skip to content

update cache keys

update cache keys #137

name: Build and Push Docker Image
on:
push:
branches:
- master
tags:
- "*"
jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: "ghcr.io/bigboot/autokuma"
dockerfile: Dockerfile
features: ""
tag_prefix: ""
- name: "ghcr.io/bigboot/kuma"
dockerfile: Dockerfile.cli
features: ""
tag_prefix: ""
- name: "ghcr.io/bigboot/autokuma"
dockerfile: Dockerfile
features: "uptime-kuma-v2"
tag_prefix: "uptime-kuma-v2-"
- name: "ghcr.io/bigboot/kuma"
dockerfile: Dockerfile.cli
features: "uptime-kuma-v2"
tag_prefix: "uptime-kuma-v2-"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ matrix.name }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr,prefix=${{ matrix.tag_prefix }}pr-
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,prefix=${{ matrix.tag_prefix }}sha-
flavor: |
latest=auto
prefix=${{ matrix.tag_prefix }},onlatest=true
suffix=
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Cache
uses: actions/cache@v3
id: cache
with:
path: |
cache
key: cache-${{ runner.os }}-cargo-${{ matrix.name }}-${{ hashFiles('**/Cargo.lock') }}
- name: inject cache into docker
uses: reproducible-containers/[email protected]
with:
cache-map: |
{
"cache": {
"target": "/cache",
"id": "cache-${{ matrix.name }}-${{ matrix.features }}",
}
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ 'linux/amd64,linux/arm64' }}
file: ${{ matrix.dockerfile }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: "FEATURES=${{ matrix.features }}"
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}