mirror of
https://gitea.com/actions/setup-java.git
synced 2025-04-07 15:59:38 +00:00
Caching on GHES (#308)
* initial changes * review comments * updated with correct message * linting * update version * updated version
This commit is contained in:
22
src/util.ts
22
src/util.ts
@ -2,6 +2,7 @@ import os from 'os';
|
||||
import path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import * as semver from 'semver';
|
||||
import * as cache from '@actions/cache';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
import * as tc from '@actions/tool-cache';
|
||||
@ -77,3 +78,24 @@ export function isJobStatusSuccess() {
|
||||
|
||||
return jobStatus === 'success';
|
||||
}
|
||||
|
||||
export function isGhes(): boolean {
|
||||
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
|
||||
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
|
||||
}
|
||||
|
||||
export function isCacheFeatureAvailable(): boolean {
|
||||
if (!cache.isFeatureAvailable()) {
|
||||
if (isGhes()) {
|
||||
throw new Error(
|
||||
'Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.'
|
||||
);
|
||||
} else {
|
||||
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user