Add cache-verify.yml
This commit is contained in:
50
.gitea/workflows/cache-verify.yml
Normal file
50
.gitea/workflows/cache-verify.yml
Normal file
@@ -0,0 +1,50 @@
|
||||
name: Cache Verify
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
cache-verify:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# 1) Show what cache/runtimes URLs the runner injected into this job
|
||||
- name: Print cache environment
|
||||
run: |
|
||||
echo "ACTIONS_CACHE_URL=${ACTIONS_CACHE_URL}"
|
||||
echo "ACTIONS_RUNTIME_URL=${ACTIONS_RUNTIME_URL}"
|
||||
|
||||
# 2) Ping the cache status endpoint (works with either host IP or service name)
|
||||
- name: Probe cache server
|
||||
run: |
|
||||
URL="${ACTIONS_CACHE_URL%/}/_apis/artifactcache/status"
|
||||
echo "Checking: $URL"
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
curl -fsS "$URL"
|
||||
else
|
||||
wget -qO- "$URL"
|
||||
fi
|
||||
|
||||
# 3) Use the cache action with a stable key
|
||||
# - First run => MISS (will SAVE at the end)
|
||||
# - Second run => HIT
|
||||
- name: Use actions/cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.cache/demo
|
||||
key: cache-verify-${{ runner.os }}-v1
|
||||
|
||||
# 4) Write a marker file so we can see reuse across runs
|
||||
- name: Write marker
|
||||
run: |
|
||||
mkdir -p ~/.cache/demo
|
||||
date -u +"%Y-%m-%dT%H:%M:%SZ" > ~/.cache/demo/when.txt
|
||||
echo "Wrote: $(cat ~/.cache/demo/when.txt)"
|
||||
|
||||
# 5) Read marker (on a cache HIT, this value will be from the previous run)
|
||||
- name: Read marker
|
||||
run: |
|
||||
echo "Marker content:"
|
||||
cat ~/.cache/demo/when.txt || echo "<missing>"
|
||||
Reference in New Issue
Block a user