refine release artifact display and chat avatars
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -29,17 +29,39 @@ function statusTone(status: string): 'neutral' | 'green' | 'amber' | 'red' | 'bl
|
|||||||
type ImageTags = {
|
type ImageTags = {
|
||||||
images?: Record<string, string>;
|
images?: Record<string, string>;
|
||||||
artifacts?: Record<string, string>;
|
artifacts?: Record<string, string>;
|
||||||
|
buildJobs?: Array<{
|
||||||
|
component?: string;
|
||||||
|
type?: string;
|
||||||
|
}>;
|
||||||
error?: string;
|
error?: string;
|
||||||
promotion?: {
|
promotion?: {
|
||||||
sourceBuildJobIds?: string[];
|
sourceBuildJobIds?: string[];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function releaseBuildComponentTypes(imageTags: ImageTags | null | undefined) {
|
||||||
|
const map = new Map<string, string>();
|
||||||
|
for (const job of imageTags?.buildJobs ?? []) {
|
||||||
|
if (job.component && job.type) map.set(job.component, job.type);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isReleaseArtifactVisible(componentName: string, componentTypes: Map<string, string>) {
|
||||||
|
const type = componentTypes.get(componentName);
|
||||||
|
return type !== 'DATABASE' && type !== 'MIGRATION';
|
||||||
|
}
|
||||||
|
|
||||||
function releaseArtifacts(release: AppRelease) {
|
function releaseArtifacts(release: AppRelease) {
|
||||||
const imageTags = release.imageTags as ImageTags | null | undefined;
|
const imageTags = release.imageTags as ImageTags | null | undefined;
|
||||||
|
const componentTypes = releaseBuildComponentTypes(imageTags);
|
||||||
const values = [
|
const values = [
|
||||||
...Object.values(imageTags?.images ?? {}),
|
...Object.entries(imageTags?.images ?? {})
|
||||||
...Object.values(imageTags?.artifacts ?? {})
|
.filter(([componentName]) => isReleaseArtifactVisible(componentName, componentTypes))
|
||||||
|
.map(([, value]) => value),
|
||||||
|
...Object.entries(imageTags?.artifacts ?? {})
|
||||||
|
.filter(([componentName]) => isReleaseArtifactVisible(componentName, componentTypes))
|
||||||
|
.map(([, value]) => value)
|
||||||
].filter(Boolean);
|
].filter(Boolean);
|
||||||
|
|
||||||
if (values.length) return values;
|
if (values.length) return values;
|
||||||
@@ -137,7 +159,9 @@ function nextReleaseVersion(releases: AppRelease[], appId: string, builds: Build
|
|||||||
|
|
||||||
function buildCount(release: AppRelease) {
|
function buildCount(release: AppRelease) {
|
||||||
const imageTags = release.imageTags as ImageTags | null | undefined;
|
const imageTags = release.imageTags as ImageTags | null | undefined;
|
||||||
const count = Object.keys(imageTags?.images ?? {}).length + Object.keys(imageTags?.artifacts ?? {}).length;
|
const componentTypes = releaseBuildComponentTypes(imageTags);
|
||||||
|
const count = Object.keys(imageTags?.images ?? {}).filter((componentName) => isReleaseArtifactVisible(componentName, componentTypes)).length
|
||||||
|
+ Object.keys(imageTags?.artifacts ?? {}).filter((componentName) => isReleaseArtifactVisible(componentName, componentTypes)).length;
|
||||||
return count || (release.artifact ? 1 : 0);
|
return count || (release.artifact ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user