Skip to content

Commit

Permalink
add cache cleanup job
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvinSchiller committed Nov 6, 2023
1 parent dc359f3 commit 78587ce
Showing 1 changed file with 7 additions and 56 deletions.
63 changes: 7 additions & 56 deletions .github/workflows/test_docker_debian_versionname_sub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ jobs:
# Run tests with build image
cleanup:
if: always()
needs: [build] #, test]
needs: [build, test]
runs-on: ${{ inputs.runs_on }}

steps:
# Load cached image file
# Lookup cached image file
- name: Cache Lookup Docker Image
id: restore-cache
uses: actions/cache/restore@v3
Expand All @@ -187,62 +187,13 @@ jobs:
path: ${{ needs.build.outputs.image_file_path }}
lookup-only: true
fail-on-cache-miss: true

- name: createTestFile
env:
FILEPATH: ${{ needs.build.outputs.image_file_path }}
run: |
touch "${FILEPATH}.testfile1.txt"
touch "${FILEPATH}.testfile2.txt"
- name: cacheTestFile1
uses: actions/cache/save@v3
with:
key: "${{ needs.build.outputs.cache_key }}.testfile1"
path: ${{ needs.build.outputs.image_file_path }}.testfile1.txt

- name: cacheTestFile2
uses: actions/cache/save@v3
with:
key: "${{ needs.build.outputs.cache_key }}.testfile2"
path: ${{ needs.build.outputs.image_file_path }}.testfile2.txt

- name: Cache Clear Docker Image 2
continue-on-error: true
#if: steps.restore-cache.outputs.cache-hit == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY: ${{ github.repository}}
CACHE_KEY: ${{ needs.build.outputs.cache_key }}
run: |
echo "--- Fetching list of cache key"
gh cache list --repo "${REPOSITORY}"
echo "--- Deleting cached key"
gh cache delete "${CACHE_KEY}.testfile1" --repo "${REPOSITORY}"
echo "--- Fetching list of cache key"
gh cache list --repo "${REPOSITORY}"
echo "--- Done"
- name: Cache Clear Docker Image 3
continue-on-error: true

- name: Cache Clear Docker Image
if: steps.restore-cache.outputs.cache-hit == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY: ${{ github.repository }}
BRANCH: ${{ github.ref }}
CACHE_KEY: ${{ needs.build.outputs.cache_key }}
run: |
gh extension install actions/gh-actions-cache
echo "--- Fetching list of cache key"
gh actions-cache list -R $REPOSITORY -B $BRANCH
echo "--- Deleting cached key"
gh actions-cache delete "${CACHE_KEY}.testfile2" -R $REPOSITORY -B $BRANCH --confirm
echo "--- Fetching list of cache key"
gh actions-cache list -R $REPOSITORY -B $BRANCH
echo "--- Done"
echo " Deleting cached key: '${CACHE_KEY}'"
gh cache delete "${CACHE_KEY}" --repo "${REPOSITORY}"

0 comments on commit 78587ce

Please sign in to comment.