@@ -1618,9 +1618,13 @@ const getOctokitClient = () => {
1618
1618
const checkIfCacheExists = (cacheKey) => __awaiter(void 0, void 0, void 0, function* () {
1619
1619
const client = getOctokitClient();
1620
1620
try {
1621
- const issueResult = yield client.request(`/repos/${github_1.context.repo.owner}/${github_1.context.repo.repo}/actions/caches`);
1622
- const caches = issueResult.data['actions_caches'] || [];
1623
- return Boolean(caches.find(cache => cache['key'] === cacheKey));
1621
+ const cachesResult = yield client.rest.actions.getActionsCacheList({
1622
+ owner: github_1.context.repo.owner,
1623
+ repo: github_1.context.repo.repo,
1624
+ key: cacheKey, // prefix matching
1625
+ });
1626
+ const caches = cachesResult.data['actions_caches'] || [];
1627
+ return caches.some(cache => cache['key'] === cacheKey);
1624
1628
}
1625
1629
catch (error) {
1626
1630
core.debug(`Error checking if cache exist: ${error.message}`);
@@ -1631,8 +1635,11 @@ const resetCacheWithOctokit = (cacheKey) => __awaiter(void 0, void 0, void 0, fu
1631
1635
const client = getOctokitClient();
1632
1636
core.debug(`remove cache "${cacheKey}"`);
1633
1637
try {
1634
- // TODO: replace with client.rest.
1635
- yield client.request(`DELETE /repos/${github_1.context.repo.owner}/${github_1.context.repo.repo}/actions/caches?key=${cacheKey}`);
1638
+ yield client.rest.actions.deleteActionsCacheByKey({
1639
+ owner: github_1.context.repo.owner,
1640
+ repo: github_1.context.repo.repo,
1641
+ key: cacheKey,
1642
+ });
1636
1643
}
1637
1644
catch (error) {
1638
1645
if (error.status) {
0 commit comments