Skip to content

ci: use day for cache key #11

ci: use day for cache key

ci: use day for cache key #11

name: build
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v4
## To avoid the trivy-db becoming outdated, we save the cache for one day
- name: Get data
id: date
run: echo "CACHE_DATE=$(date +%Y-%m-%d)" >> $GITHUB_ENV
- name: Restore trivy cache
uses: actions/cache@v4
with:
path: cache/db
key: trivy-cache-${{ env.CACHE_DATE }}
restore-keys:
trivy-cache-
- name: Run Trivy vulnerability scanner in fs mode
uses: aquasecurity/trivy-action@0.24.0
with:
scan-type: 'fs'
scan-ref: '.'
cache-dir: "./cache"
## Trivy-db uses `0600` permissions.
## But `action/cache` use `runner` user by default
## So we need to change the permissions before caching the database.
- name: change permissions for trivy.db
run: sudo chmod 0644 ./cache/db/trivy.db