Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/cache_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Cache Test

on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
cache:
runs-on: ubuntu-latest
steps:
- name: Get current date
id: date
run: echo "date=$(date +%s)" >> $GITHUB_OUTPUT
- name: Cache Directly
id: cache
uses: actions/cache@v3
with:
path: tmp/directly.log
key: directly-${{ github.run_id }}-${{ steps.date.outputs.date }}
restore-keys: |
directly-
- name: Copy the directly file
if: steps.cache.outputs.cache-hit
run: |
cp tmp/directly.log tmp/directly_restored.log
- name: Restore
uses: actions/cache/restore@v3
with:
path: tmp/test-cached.log
key: test-key
restore-keys: |
test-key

- name: Do something
run: |
echo "Showing restored log"
mkdir -p tmp
ls tmp/
cp tmp/test-cached.log tmp/test-restored.log || true
echo "-------cache/restore--------"
touch tmp/test-restored.log
cat tmp/test-restored.log
echo "-------directly--------"
touch tmp/directly_restored.log
cat tmp/directly_restored.log

D=$(date '+%Y-%m-%d %H:%M:%s')
echo "Generate a new log: $D"
echo $D > tmp/test-cached.log
echo $D > tmp/directly.log

- name: Cache
if: always()
uses: actions/cache/save@v3
with:
path: tmp/test-cached.log
key: test-key-${{ github.run_id }}-${{ hashFiles('**/test-cached.log') }} # Can use time based key as well
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Click the pencil icon in the upper right corner of the file view to edit.
In the editor, write a bit about yourself.
Write a commit message that describes your changes.
Click Commit changes button.
test