1
0
Fork 0
mirror of https://code.forgejo.org/actions/setup-node synced 2025-06-12 23:04:13 +02:00

Caching on GHES (#452)

* add support for ghes caching

* fix licesnses

* work on resolving comments

* change internal error to warning

* fix warning for internal errors

* update version
This commit is contained in:
Dmitry Shibanov 2022-03-31 21:10:37 +02:00 committed by GitHub
parent bed538bd04
commit bacd6b4b3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 192 additions and 67 deletions

View file

@ -4,7 +4,7 @@ import fs from 'fs';
import * as auth from './authutil';
import * as path from 'path';
import {restoreCache} from './cache-restore';
import {URL} from 'url';
import {isGhes, isCacheFeatureAvailable} from './cache-utils';
import os = require('os');
export async function run() {
@ -45,10 +45,7 @@ export async function run() {
auth.configAuthentication(registryUrl, alwaysAuth);
}
if (cache) {
if (isGhes()) {
throw new Error('Caching is not supported on GHES');
}
if (cache && isCacheFeatureAvailable()) {
const cacheDependencyPath = core.getInput('cache-dependency-path');
await restoreCache(cache, cacheDependencyPath);
}
@ -66,13 +63,6 @@ export async function run() {
}
}
function isGhes(): boolean {
const ghUrl = new URL(
process.env['GITHUB_SERVER_URL'] || 'https://github.com'
);
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
}
function resolveVersionInput(): string {
let version = core.getInput('node-version');
const versionFileInput = core.getInput('node-version-file');