refactor debug logging
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="116" height="20" role="img" aria-label="Coverage: 93.53%"><title>Coverage: 93.53%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="116" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="63" height="20" fill="#555"/><rect x="63" width="53" height="20" fill="#4c1"/><rect width="116" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="325" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">Coverage</text><text x="325" y="140" transform="scale(.1)" fill="#fff" textLength="530">Coverage</text><text aria-hidden="true" x="885" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">93.53%</text><text x="885" y="140" transform="scale(.1)" fill="#fff" textLength="430">93.53%</text></g></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="116" height="20" role="img" aria-label="Coverage: 93.96%"><title>Coverage: 93.96%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="116" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="63" height="20" fill="#555"/><rect x="63" width="53" height="20" fill="#4c1"/><rect width="116" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="325" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">Coverage</text><text x="325" y="140" transform="scale(.1)" fill="#fff" textLength="530">Coverage</text><text aria-hidden="true" x="885" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">93.96%</text><text x="885" y="140" transform="scale(.1)" fill="#fff" textLength="430">93.96%</text></g></svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
+7
-10
@@ -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);
|
||||
|
||||
+6
-12
@@ -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<Response> => {
|
||||
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
|
||||
|
||||
+1
-2
@@ -74,8 +74,7 @@ export async function run(): Promise<void> {
|
||||
semanticVersion.raw,
|
||||
archives.zipFile,
|
||||
archives.tarFile,
|
||||
manifest,
|
||||
true
|
||||
manifest
|
||||
)
|
||||
|
||||
core.setOutput('package-url', packageURL.toString())
|
||||
|
||||
Reference in New Issue
Block a user