Skip to content

Commit

Permalink
feat: cache-suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 committed Oct 21, 2022
1 parent c07b3e0 commit 8438a24
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
with:
release-name: v0.3.0
cache-key: ${{ runner.os }}-sccache
cache-save: ${{ github.event_name != 'pull_request' }}
cache-suffix: ${{ github.event_name != 'pull_request' }}
- run: sccache -s
- run: cargo build -v
env:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ This repository provides GitHub Actions which enables projects to cache the comp
cache-key: sccache-ubuntu-latest
# Optional
cache-save: true
# Optional
cache-suffix: true
# Optional, e.g. v0.3.0
release-name: latest
# Optional
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ inputs:
cache-save:
description: "A Flag that indicates whether or not saving the cache"
default: true
cache-suffix:
description: "A Flag that indicates whether or not appending timestamp suffix to the cache key when saving"
default: true
release-name:
description: "The sccache version. e.g. v0.3.0"
default: "latest"
Expand Down
2 changes: 1 addition & 1 deletion dist/post/index.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export const saveCache = async () => {
console.log(`Aborting, shouldSaveCache: ${shouldSaveCache}`);
return;
}
const cacheKey = `${core.getInput('cache-key')}-${new Date().toISOString()}`;
const shouldAppendSuffix = core.getBooleanInput('cache-suffix');
console.log(`shouldAppendSuffix: ${shouldAppendSuffix}`);
const cacheKey = shouldAppendSuffix ? `${core.getInput('cache-key')}-${new Date().toISOString()}` : core.getInput('cache-key');
console.log(`Using cacheKey: ${cacheKey}`);
await cache.saveCache([`${process.env.HOME}/.cache/sccache`, `${process.env.HOME}/Library/Caches/Mozilla.sccache`], cacheKey);
} catch (err: any) {
Expand Down

0 comments on commit 8438a24

Please sign in to comment.