Clean docker image cache (#1636)

This commit is contained in:
erabii
2024-04-17 17:13:15 +03:00
committed by GitHub
parent c7c4220047
commit 013b920bcf
26 changed files with 283 additions and 48 deletions

View File

@@ -21,4 +21,3 @@ runs:
echo "BRANCH_NAME=$(echo $GITHUB_HEAD_REF)" >> $GITHUB_ENV
echo "BASE_BRANCH_NAME=$(echo $GITHUB_BASE_REF)" >> $GITHUB_ENV
echo "DOCKER_IMAGES_KEY=$(echo $GITHUB_RUN_ID)" >> $GITHUB_ENV

View File

@@ -22,6 +22,9 @@ runs:
- name: cache local maven repository
uses: ./.github/workflows/composites/cache
- name: restore common images
uses: ./.github/workflows/composites/restore-docker-images
- name: build project
shell: bash
run: |

View File

@@ -0,0 +1,42 @@
name: restore-docker-images
description: upload docker images
runs:
using: "composite"
steps:
- name: restore images if cache matches
uses: actions/cache/restore@v4
id: images-cache
with:
path: /tmp/docker/images
key: docker-images-github-cache-${{ hashFiles('**/current-images.txt') }}
- name: pull docker images
shell: bash
if: steps.images-cache.outputs.cache-hit != 'true'
run: |
echo 'start pulling common images'
mkdir -p /tmp/docker/images
result=$(find . -name 'current-images.txt')
while read line; do
docker pull "$line"
replace_slash=$(tr '/' '-' <<< "$line")
docker save "${line}" > "/tmp/docker/images/${replace_slash}.tar"
done <$result
- name: save docker images
id: save-docker-images
uses: actions/cache/save@v4
if: steps.images-cache.outputs.cache-hit != 'true'
with:
path: |
/tmp/docker/images
key: docker-images-github-cache-${{ hashFiles('**/current-images.txt') }}
- name: print images
shell: bash
run: |
echo 'printing images'
ls /tmp/docker/images

View File

@@ -1,19 +0,0 @@
# we are not going to use upload/download actions, since it is slower than cache usage
# as key to the cache we are going to use DOCKER_IMAGES_KEY, which is the same as GITHUB_RUN_ID
name: upload docker images
description: upload docker images
runs:
using: "composite"
steps:
- uses: Wandalen/wretry.action@master
with:
attempt_limit: 3
action: buildjet/cache@v3
with: |
path: /tmp/docker/images
key: docker-images-cache-${{ env.DOCKER_IMAGES_KEY }}
restore-keys: docker-images-cache-${{ env.DOCKER_IMAGES_KEY }}