diff --git a/badges/coverage.svg b/badges/coverage.svg index 782e243..c528674 100644 --- a/badges/coverage.svg +++ b/badges/coverage.svg @@ -1 +1 @@ -Coverage: 93.53%Coverage93.53% +Coverage: 93.96%Coverage93.96% diff --git a/dist/index.js b/dist/index.js index 01bf81a..13f3303 100644 --- a/dist/index.js +++ b/dist/index.js @@ -70986,12 +70986,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.publishOCIArtifact = void 0; const core = __importStar(__nccwpck_require__(2186)); const fsHelper = __importStar(__nccwpck_require__(6642)); -let showDebugLog = false; // Publish the OCI artifact and return the URL where it can be downloaded -async function publishOCIArtifact(token, registry, repository, semver, zipFile, tarFile, manifest, debugRequests = false) { - if (debugRequests) { - showDebugLog = true; - } +async function publishOCIArtifact(token, registry, repository, semver, zipFile, tarFile, manifest) { const b64Token = Buffer.from(token).toString('base64'); const checkBlobEndpoint = new URL(`v2/${repository}/blobs/`, registry).toString(); const uploadBlobEndpoint = new URL(`v2/${repository}/blobs/uploads/`, registry).toString(); @@ -71093,18 +71089,19 @@ async function uploadManifest(manifestJSON, manifestEndpoint, b64Token) { return digestResponseHeader; } const fetchWithDebug = async (url, config = {}) => { - if (showDebugLog) { - core.debug(`Request with ${JSON.stringify(config)}`); + const debugLogs = core.isDebug(); + if (debugLogs) { + core.debug(`Request from ${url} with config: ${JSON.stringify(config)}`); } try { const response = await fetch(url, config); - if (showDebugLog) { + if (debugLogs) { core.debug(`Response with ${JSON.stringify(response)}`); } return response; } catch (error) { - if (showDebugLog) { + if (debugLogs) { core.debug(`Error with ${error}`); } throw error; @@ -71191,7 +71188,7 @@ async function run() { const manifest = ociContainer.createActionPackageManifest(archives.tarFile, archives.zipFile, repository, repoId, ownerId, sourceCommit, semanticVersion.raw, new Date()); const containerRegistryURL = await api.getContainerRegistryURL(); console.log(`Container registry URL: ${containerRegistryURL}`); - const { packageURL, manifestDigest } = await ghcr.publishOCIArtifact(token, containerRegistryURL, repository, semanticVersion.raw, archives.zipFile, archives.tarFile, manifest, true); + const { packageURL, manifestDigest } = await ghcr.publishOCIArtifact(token, containerRegistryURL, repository, semanticVersion.raw, archives.zipFile, archives.tarFile, manifest); core.setOutput('package-url', packageURL.toString()); core.setOutput('package-manifest', JSON.stringify(manifest)); core.setOutput('package-manifest-sha', manifestDigest); diff --git a/src/ghcr-client.ts b/src/ghcr-client.ts index 0ec2832..0d1c049 100644 --- a/src/ghcr-client.ts +++ b/src/ghcr-client.ts @@ -3,8 +3,6 @@ import { FileMetadata } from './fs-helper' import * as ociContainer from './oci-container' import * as fsHelper from './fs-helper' -let showDebugLog = false - // Publish the OCI artifact and return the URL where it can be downloaded export async function publishOCIArtifact( token: string, @@ -13,13 +11,8 @@ export async function publishOCIArtifact( semver: string, zipFile: FileMetadata, tarFile: FileMetadata, - manifest: ociContainer.Manifest, - debugRequests = false + manifest: ociContainer.Manifest ): Promise<{ packageURL: URL; manifestDigest: string }> { - if (debugRequests) { - showDebugLog = true - } - const b64Token = Buffer.from(token).toString('base64') const checkBlobEndpoint = new URL( @@ -211,17 +204,18 @@ const fetchWithDebug = async ( url: string, config: RequestInit = {} ): Promise => { - if (showDebugLog) { - core.debug(`Request with ${JSON.stringify(config)}`) + const debugLogs = core.isDebug() + if (debugLogs) { + core.debug(`Request from ${url} with config: ${JSON.stringify(config)}`) } try { const response = await fetch(url, config) - if (showDebugLog) { + if (debugLogs) { core.debug(`Response with ${JSON.stringify(response)}`) } return response } catch (error) { - if (showDebugLog) { + if (debugLogs) { core.debug(`Error with ${error}`) } throw error diff --git a/src/main.ts b/src/main.ts index be35c96..4dea7bc 100644 --- a/src/main.ts +++ b/src/main.ts @@ -74,8 +74,7 @@ export async function run(): Promise { semanticVersion.raw, archives.zipFile, archives.tarFile, - manifest, - true + manifest ) core.setOutput('package-url', packageURL.toString())