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;
|
exports.publishOCIArtifact = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const fsHelper = __importStar(__nccwpck_require__(6642));
|
const fsHelper = __importStar(__nccwpck_require__(6642));
|
||||||
let showDebugLog = false;
|
|
||||||
// Publish the OCI artifact and return the URL where it can be downloaded
|
// 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) {
|
async function publishOCIArtifact(token, registry, repository, semver, zipFile, tarFile, manifest) {
|
||||||
if (debugRequests) {
|
|
||||||
showDebugLog = true;
|
|
||||||
}
|
|
||||||
const b64Token = Buffer.from(token).toString('base64');
|
const b64Token = Buffer.from(token).toString('base64');
|
||||||
const checkBlobEndpoint = new URL(`v2/${repository}/blobs/`, registry).toString();
|
const checkBlobEndpoint = new URL(`v2/${repository}/blobs/`, registry).toString();
|
||||||
const uploadBlobEndpoint = new URL(`v2/${repository}/blobs/uploads/`, registry).toString();
|
const uploadBlobEndpoint = new URL(`v2/${repository}/blobs/uploads/`, registry).toString();
|
||||||
@@ -71093,18 +71089,19 @@ async function uploadManifest(manifestJSON, manifestEndpoint, b64Token) {
|
|||||||
return digestResponseHeader;
|
return digestResponseHeader;
|
||||||
}
|
}
|
||||||
const fetchWithDebug = async (url, config = {}) => {
|
const fetchWithDebug = async (url, config = {}) => {
|
||||||
if (showDebugLog) {
|
const debugLogs = core.isDebug();
|
||||||
core.debug(`Request with ${JSON.stringify(config)}`);
|
if (debugLogs) {
|
||||||
|
core.debug(`Request from ${url} with config: ${JSON.stringify(config)}`);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url, config);
|
const response = await fetch(url, config);
|
||||||
if (showDebugLog) {
|
if (debugLogs) {
|
||||||
core.debug(`Response with ${JSON.stringify(response)}`);
|
core.debug(`Response with ${JSON.stringify(response)}`);
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
if (showDebugLog) {
|
if (debugLogs) {
|
||||||
core.debug(`Error with ${error}`);
|
core.debug(`Error with ${error}`);
|
||||||
}
|
}
|
||||||
throw 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 manifest = ociContainer.createActionPackageManifest(archives.tarFile, archives.zipFile, repository, repoId, ownerId, sourceCommit, semanticVersion.raw, new Date());
|
||||||
const containerRegistryURL = await api.getContainerRegistryURL();
|
const containerRegistryURL = await api.getContainerRegistryURL();
|
||||||
console.log(`Container registry URL: ${containerRegistryURL}`);
|
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-url', packageURL.toString());
|
||||||
core.setOutput('package-manifest', JSON.stringify(manifest));
|
core.setOutput('package-manifest', JSON.stringify(manifest));
|
||||||
core.setOutput('package-manifest-sha', manifestDigest);
|
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 ociContainer from './oci-container'
|
||||||
import * as fsHelper from './fs-helper'
|
import * as fsHelper from './fs-helper'
|
||||||
|
|
||||||
let showDebugLog = false
|
|
||||||
|
|
||||||
// Publish the OCI artifact and return the URL where it can be downloaded
|
// Publish the OCI artifact and return the URL where it can be downloaded
|
||||||
export async function publishOCIArtifact(
|
export async function publishOCIArtifact(
|
||||||
token: string,
|
token: string,
|
||||||
@@ -13,13 +11,8 @@ export async function publishOCIArtifact(
|
|||||||
semver: string,
|
semver: string,
|
||||||
zipFile: FileMetadata,
|
zipFile: FileMetadata,
|
||||||
tarFile: FileMetadata,
|
tarFile: FileMetadata,
|
||||||
manifest: ociContainer.Manifest,
|
manifest: ociContainer.Manifest
|
||||||
debugRequests = false
|
|
||||||
): Promise<{ packageURL: URL; manifestDigest: string }> {
|
): Promise<{ packageURL: URL; manifestDigest: string }> {
|
||||||
if (debugRequests) {
|
|
||||||
showDebugLog = true
|
|
||||||
}
|
|
||||||
|
|
||||||
const b64Token = Buffer.from(token).toString('base64')
|
const b64Token = Buffer.from(token).toString('base64')
|
||||||
|
|
||||||
const checkBlobEndpoint = new URL(
|
const checkBlobEndpoint = new URL(
|
||||||
@@ -211,17 +204,18 @@ const fetchWithDebug = async (
|
|||||||
url: string,
|
url: string,
|
||||||
config: RequestInit = {}
|
config: RequestInit = {}
|
||||||
): Promise<Response> => {
|
): Promise<Response> => {
|
||||||
if (showDebugLog) {
|
const debugLogs = core.isDebug()
|
||||||
core.debug(`Request with ${JSON.stringify(config)}`)
|
if (debugLogs) {
|
||||||
|
core.debug(`Request from ${url} with config: ${JSON.stringify(config)}`)
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url, config)
|
const response = await fetch(url, config)
|
||||||
if (showDebugLog) {
|
if (debugLogs) {
|
||||||
core.debug(`Response with ${JSON.stringify(response)}`)
|
core.debug(`Response with ${JSON.stringify(response)}`)
|
||||||
}
|
}
|
||||||
return response
|
return response
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (showDebugLog) {
|
if (debugLogs) {
|
||||||
core.debug(`Error with ${error}`)
|
core.debug(`Error with ${error}`)
|
||||||
}
|
}
|
||||||
throw error
|
throw error
|
||||||
|
|||||||
+1
-2
@@ -74,8 +74,7 @@ export async function run(): Promise<void> {
|
|||||||
semanticVersion.raw,
|
semanticVersion.raw,
|
||||||
archives.zipFile,
|
archives.zipFile,
|
||||||
archives.tarFile,
|
archives.tarFile,
|
||||||
manifest,
|
manifest
|
||||||
true
|
|
||||||
)
|
)
|
||||||
|
|
||||||
core.setOutput('package-url', packageURL.toString())
|
core.setOutput('package-url', packageURL.toString())
|
||||||
|
|||||||
Reference in New Issue
Block a user