mirror of
https://github.com/actions/stale.git
synced 2025-12-28 02:58:17 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a21a081629 |
17
dist/index.js
vendored
17
dist/index.js
vendored
@@ -1646,9 +1646,13 @@ const getOctokitClient = () => {
|
|||||||
const checkIfCacheExists = (cacheKey) => __awaiter(void 0, void 0, void 0, function* () {
|
const checkIfCacheExists = (cacheKey) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const client = getOctokitClient();
|
const client = getOctokitClient();
|
||||||
try {
|
try {
|
||||||
const issueResult = yield client.request(`/repos/${github_1.context.repo.owner}/${github_1.context.repo.repo}/actions/caches`);
|
const cachesResult = yield client.rest.actions.getActionsCacheList({
|
||||||
const caches = issueResult.data['actions_caches'] || [];
|
owner: github_1.context.repo.owner,
|
||||||
return Boolean(caches.find(cache => cache['key'] === cacheKey));
|
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) {
|
catch (error) {
|
||||||
core.debug(`Error checking if cache exist: ${error.message}`);
|
core.debug(`Error checking if cache exist: ${error.message}`);
|
||||||
@@ -1659,8 +1663,11 @@ const resetCacheWithOctokit = (cacheKey) => __awaiter(void 0, void 0, void 0, fu
|
|||||||
const client = getOctokitClient();
|
const client = getOctokitClient();
|
||||||
core.debug(`remove cache "${cacheKey}"`);
|
core.debug(`remove cache "${cacheKey}"`);
|
||||||
try {
|
try {
|
||||||
// TODO: replace with client.rest.
|
yield client.rest.actions.deleteActionsCacheByKey({
|
||||||
yield client.request(`DELETE /repos/${github_1.context.repo.owner}/${github_1.context.repo.repo}/actions/caches?key=${cacheKey}`);
|
owner: github_1.context.repo.owner,
|
||||||
|
repo: github_1.context.repo.repo,
|
||||||
|
key: cacheKey
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
if (error.status) {
|
if (error.status) {
|
||||||
|
|||||||
@@ -33,12 +33,14 @@ const getOctokitClient = () => {
|
|||||||
const checkIfCacheExists = async (cacheKey: string): Promise<boolean> => {
|
const checkIfCacheExists = async (cacheKey: string): Promise<boolean> => {
|
||||||
const client = getOctokitClient();
|
const client = getOctokitClient();
|
||||||
try {
|
try {
|
||||||
const issueResult = await client.request(
|
const cachesResult = await client.rest.actions.getActionsCacheList({
|
||||||
`/repos/${context.repo.owner}/${context.repo.repo}/actions/caches`
|
owner: context.repo.owner,
|
||||||
);
|
repo: context.repo.repo,
|
||||||
|
key: cacheKey // prefix matching
|
||||||
|
});
|
||||||
const caches: Array<{key?: string}> =
|
const caches: Array<{key?: string}> =
|
||||||
issueResult.data['actions_caches'] || [];
|
cachesResult.data['actions_caches'] || [];
|
||||||
return Boolean(caches.find(cache => cache['key'] === cacheKey));
|
return caches.some(cache => cache['key'] === cacheKey);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.debug(`Error checking if cache exist: ${error.message}`);
|
core.debug(`Error checking if cache exist: ${error.message}`);
|
||||||
}
|
}
|
||||||
@@ -48,10 +50,11 @@ const resetCacheWithOctokit = async (cacheKey: string): Promise<void> => {
|
|||||||
const client = getOctokitClient();
|
const client = getOctokitClient();
|
||||||
core.debug(`remove cache "${cacheKey}"`);
|
core.debug(`remove cache "${cacheKey}"`);
|
||||||
try {
|
try {
|
||||||
// TODO: replace with client.rest.
|
await client.rest.actions.deleteActionsCacheByKey({
|
||||||
await client.request(
|
owner: context.repo.owner,
|
||||||
`DELETE /repos/${context.repo.owner}/${context.repo.repo}/actions/caches?key=${cacheKey}`
|
repo: context.repo.repo,
|
||||||
);
|
key: cacheKey
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.status) {
|
if (error.status) {
|
||||||
core.warning(
|
core.warning(
|
||||||
|
|||||||
Reference in New Issue
Block a user