Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4777cc4

Browse filesBrowse files
committed
Fix checking state cache (fix #1136), also switch to octokit methods
1 parent 9971854 commit 4777cc4
Copy full SHA for 4777cc4

File tree

Expand file treeCollapse file tree

2 files changed

+24
-14
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+24
-14
lines changed
Open diff view settings
Collapse file

‎dist/index.js‎

Copy file name to clipboardExpand all lines: dist/index.js
+12-5Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,9 +1646,13 @@ const getOctokitClient = () => {
16461646
const checkIfCacheExists = (cacheKey) => __awaiter(void 0, void 0, void 0, function* () {
16471647
const client = getOctokitClient();
16481648
try {
1649-
const issueResult = yield client.request(`/repos/${github_1.context.repo.owner}/${github_1.context.repo.repo}/actions/caches`);
1650-
const caches = issueResult.data['actions_caches'] || [];
1651-
return Boolean(caches.find(cache => cache['key'] === cacheKey));
1649+
const cachesResult = yield client.rest.actions.getActionsCacheList({
1650+
owner: github_1.context.repo.owner,
1651+
repo: github_1.context.repo.repo,
1652+
key: cacheKey // prefix matching
1653+
});
1654+
const caches = cachesResult.data['actions_caches'] || [];
1655+
return caches.some(cache => cache['key'] === cacheKey);
16521656
}
16531657
catch (error) {
16541658
core.debug(`Error checking if cache exist: ${error.message}`);
@@ -1659,8 +1663,11 @@ const resetCacheWithOctokit = (cacheKey) => __awaiter(void 0, void 0, void 0, fu
16591663
const client = getOctokitClient();
16601664
core.debug(`remove cache "${cacheKey}"`);
16611665
try {
1662-
// TODO: replace with client.rest.
1663-
yield client.request(`DELETE /repos/${github_1.context.repo.owner}/${github_1.context.repo.repo}/actions/caches?key=${cacheKey}`);
1666+
yield client.rest.actions.deleteActionsCacheByKey({
1667+
owner: github_1.context.repo.owner,
1668+
repo: github_1.context.repo.repo,
1669+
key: cacheKey
1670+
});
16641671
}
16651672
catch (error) {
16661673
if (error.status) {
Collapse file

‎src/classes/state/state-cache-storage.ts‎

Copy file name to clipboardExpand all lines: src/classes/state/state-cache-storage.ts
+12-9Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ const getOctokitClient = () => {
3333
const checkIfCacheExists = async (cacheKey: string): Promise<boolean> => {
3434
const client = getOctokitClient();
3535
try {
36-
const issueResult = await client.request(
37-
`/repos/${context.repo.owner}/${context.repo.repo}/actions/caches`
38-
);
36+
const cachesResult = await client.rest.actions.getActionsCacheList({
37+
owner: context.repo.owner,
38+
repo: context.repo.repo,
39+
key: cacheKey // prefix matching
40+
});
3941
const caches: Array<{key?: string}> =
40-
issueResult.data['actions_caches'] || [];
41-
return Boolean(caches.find(cache => cache['key'] === cacheKey));
42+
cachesResult.data['actions_caches'] || [];
43+
return caches.some(cache => cache['key'] === cacheKey);
4244
} catch (error) {
4345
core.debug(`Error checking if cache exist: ${error.message}`);
4446
}
@@ -48,10 +50,11 @@ const resetCacheWithOctokit = async (cacheKey: string): Promise<void> => {
4850
const client = getOctokitClient();
4951
core.debug(`remove cache "${cacheKey}"`);
5052
try {
51-
// TODO: replace with client.rest.
52-
await client.request(
53-
`DELETE /repos/${context.repo.owner}/${context.repo.repo}/actions/caches?key=${cacheKey}`
54-
);
53+
await client.rest.actions.deleteActionsCacheByKey({
54+
owner: context.repo.owner,
55+
repo: context.repo.repo,
56+
key: cacheKey
57+
});
5558
} catch (error) {
5659
if (error.status) {
5760
core.warning(

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.