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
17 changes: 12 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1618,9 +1618,13 @@ const getOctokitClient = () => {
const checkIfCacheExists = (cacheKey) => __awaiter(void 0, void 0, void 0, function* () {
const client = getOctokitClient();
try {
const issueResult = yield client.request(`/repos/${github_1.context.repo.owner}/${github_1.context.repo.repo}/actions/caches`);
const caches = issueResult.data['actions_caches'] || [];
return Boolean(caches.find(cache => cache['key'] === cacheKey));
const cachesResult = yield client.rest.actions.getActionsCacheList({
owner: github_1.context.repo.owner,
repo: github_1.context.repo.repo,
key: cacheKey, // prefix matching
});
const caches = cachesResult.data['actions_caches'] || [];
return caches.some(cache => cache['key'] === cacheKey);
}
catch (error) {
core.debug(`Error checking if cache exist: ${error.message}`);
Expand All @@ -1631,8 +1635,11 @@ const resetCacheWithOctokit = (cacheKey) => __awaiter(void 0, void 0, void 0, fu
const client = getOctokitClient();
core.debug(`remove cache "${cacheKey}"`);
try {
// TODO: replace with client.rest.
yield client.request(`DELETE /repos/${github_1.context.repo.owner}/${github_1.context.repo.repo}/actions/caches?key=${cacheKey}`);
yield client.rest.actions.deleteActionsCacheByKey({
owner: github_1.context.repo.owner,
repo: github_1.context.repo.repo,
key: cacheKey,
});
}
catch (error) {
if (error.status) {
Expand Down
21 changes: 12 additions & 9 deletions src/classes/state/state-cache-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ const getOctokitClient = () => {
const checkIfCacheExists = async (cacheKey: string): Promise<boolean> => {
const client = getOctokitClient();
try {
const issueResult = await client.request(
`/repos/${context.repo.owner}/${context.repo.repo}/actions/caches`
);
const cachesResult = await client.rest.actions.getActionsCacheList({
owner: context.repo.owner,
repo: context.repo.repo,
key: cacheKey, // prefix matching
});
const caches: Array<{key?: string}> =
issueResult.data['actions_caches'] || [];
return Boolean(caches.find(cache => cache['key'] === cacheKey));
cachesResult.data['actions_caches'] || [];
return caches.some(cache => cache['key'] === cacheKey);
} catch (error) {
core.debug(`Error checking if cache exist: ${error.message}`);
}
Expand All @@ -48,10 +50,11 @@ const resetCacheWithOctokit = async (cacheKey: string): Promise<void> => {
const client = getOctokitClient();
core.debug(`remove cache "${cacheKey}"`);
try {
// TODO: replace with client.rest.
await client.request(
`DELETE /repos/${context.repo.owner}/${context.repo.repo}/actions/caches?key=${cacheKey}`
);
await client.rest.actions.deleteActionsCacheByKey({
owner: context.repo.owner,
repo: context.repo.repo,
key: cacheKey,
});
} catch (error) {
if (error.status) {
core.warning(
Expand Down
Loading