Skip to content

Auto Clean CI Cache #137

Auto Clean CI Cache

Auto Clean CI Cache #137

name: Auto Clean CI Cache
# Any change in triggers needs to be reflected in the concurrency group.
on:
workflow_dispatch:
schedule:
# run 4:00 am once for a week, in shanghai timezone
# cron by UTC, shanghai timezone = UTC + 8
- cron: "0 20 * * 0"
permissions: read-all
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.after }}
cancel-in-progress: true
jobs:
cache-cleaner:
runs-on: ubuntu-latest
strategy:
matrix:
include:
# for each image
- name: controllerimage
steps:
# Load Golang cache build from GitHub
- name: Load ${{ matrix.name }} Golang cache build from GitHub
uses: actions/[email protected]
id: cache
with:
path: /tmp/.cache/${{ matrix.name }}
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ matrix.name }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ matrix.name }}-
${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-
${{ runner.os }}-go-
- name: Create ${{ matrix.name }} cache directory
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
mkdir -p /tmp/.cache/${{ matrix.name }}
# Clean docker's golang's cache
- name: Clean ${{ matrix.name }} Golang cache from GitHub
shell: bash
run: |
rm -f /tmp/.cache/${{ matrix.name }}/go-build-cache.tar.gz
rm -f /tmp/.cache/${{ matrix.name }}/go-pkg-cache.tar.gz