Clean docker image cache (#1636)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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: |
|
||||
|
||||
42
.github/workflows/composites/restore-docker-images/action.yaml
vendored
Normal file
42
.github/workflows/composites/restore-docker-images/action.yaml
vendored
Normal 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
|
||||
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user