Skip to content

Create cache

Create cache #257

name: Publish Docker #
on:
push:
branches:
- master
schedule:
- cron: '0 2 * * 0' # Weekly on Sundays at 02:00
permissions:
contents: write
jobs:
check:
runs-on: ubuntu-latest
outputs:
image-needs-updating: ${{ steps.check.outputs.needs-updating }}
steps:
- name: Docker Image Update Checker
id: check
uses: lucacome/docker-image-update-checker@v1.2.1
with:
base-image: library/nextcloud:latest
image: ${{ github.repository }}:latest
if: ${{ github.event_name == 'schedule' }}
build:
needs: check
if: ${{ github.event_name != 'schedule' || needs.check.outputs.image-needs-updating == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: false
tags: ${{ github.repository }}:latest
platforms: linux/amd64,linux/arm64
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- # Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cach
- uses: kitabisa/docker-slim-action@v1
env:
DSLIM_HTTP_PROBE: false
DSLIM_PULL: false
DSLIM_IMAGE_BUILD_ARCH: amd64
DSLIM_HOST_EXEC: "/bin/bash ls && php-fpm"
with:
target: ${{ github.repository }}:latest
tag: "slim"
- run: docker image push "${{ github.repository }}" --all-tags
- uses: gautamkrishnar/keepalive-workflow@v1 # using the workflow with default settings