diff --git a/.github/workflows/cache_test.yml b/.github/workflows/cache_test.yml new file mode 100644 index 0000000..ba99ecd --- /dev/null +++ b/.github/workflows/cache_test.yml @@ -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 diff --git a/README b/README index ddf3bc5..b6fb4b1 100644 --- a/README +++ b/README @@ -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