Skip to content

Commit f0de040

Browse files
committed
Improve debugging
1 parent 1a8a264 commit f0de040

File tree

4 files changed

+112
-14
lines changed

4 files changed

+112
-14
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ ___
3939
* [Notes](#notes)
4040
* [Latest tag](#latest-tag)
4141
* [Overwrite labels](#overwrite-labels)
42+
* [Debug](#debug)
4243
* [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
4344
* [Contributing](#contributing)
4445
* [License](#license)
@@ -573,6 +574,10 @@ labels generated are not suitable, you can overwrite them like this:
573574
org.opencontainers.image.vendor=MyCompany
574575
```
575576

577+
### Debug
578+
579+
For more details, please enable debug logs by [adding secret `ACTIONS_STEP_DEBUG=true`](https://docs.github.com/en/actions/managing-workflow-runs/enabling-debug-logging#enabling-step-debug-logging).
580+
576581
## Keep up-to-date with GitHub Dependabot
577582

578583
Since [Dependabot](https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-github-dependabot)

dist/index.js

Lines changed: 70 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/flavor.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import * as core from '@actions/core';
2+
13
export interface Flavor {
24
latest: string;
35
prefix: string;
@@ -38,5 +40,11 @@ export function Transform(inputs: string[]): Flavor {
3840
}
3941
}
4042

43+
if (core.isDebug()) {
44+
core.startGroup(`Parsing flavor input`);
45+
core.debug([`latest=${flavor.latest}`, `prefix=${flavor.prefix}`, `suffix=${flavor.suffix}`].join(','));
46+
core.endGroup();
47+
}
48+
4149
return flavor;
4250
}

src/tag.ts

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import csvparse from 'csv-parse/lib/sync';
2+
import * as core from '@actions/core';
23

34
export enum Type {
45
Schedule = 'schedule',
@@ -16,9 +17,21 @@ export enum RefEvent {
1617
PR = 'pr'
1718
}
1819

19-
export interface Tag {
20-
type: Type;
21-
attrs: Record<string, string>;
20+
export class Tag {
21+
public type?: Type;
22+
public attrs: Record<string, string>;
23+
24+
constructor() {
25+
this.attrs = {};
26+
}
27+
28+
public toString(): string {
29+
const out: string[] = [`type=${this.type}`];
30+
for (let attr in this.attrs) {
31+
out.push(`${attr}=${this.attrs[attr]}`);
32+
}
33+
return out.join(',');
34+
}
2235
}
2336

2437
export const DefaultPriorities: Record<Type, string> = {
@@ -42,10 +55,11 @@ export function Transform(inputs: string[]): Tag[] {
4255
`type=ref,event=${RefEvent.PR}`
4356
];
4457
}
58+
4559
for (const input of inputs) {
4660
tags.push(Parse(input));
4761
}
48-
return tags.sort((tag1, tag2) => {
62+
const sorted = tags.sort((tag1, tag2) => {
4963
if (Number(tag1.attrs['priority']) < Number(tag2.attrs['priority'])) {
5064
return 1;
5165
}
@@ -54,6 +68,16 @@ export function Transform(inputs: string[]): Tag[] {
5468
}
5569
return 0;
5670
});
71+
72+
if (core.isDebug()) {
73+
core.startGroup(`Parsing tags input`);
74+
for (const tag of sorted) {
75+
core.debug(tag.toString());
76+
}
77+
core.endGroup();
78+
}
79+
80+
return sorted;
5781
}
5882

5983
export function Parse(s: string): Tag {
@@ -62,10 +86,7 @@ export function Parse(s: string): Tag {
6286
skipLinesWithEmptyValues: true
6387
})[0];
6488

65-
const tag = {
66-
attrs: {}
67-
} as Tag;
68-
89+
const tag = new Tag();
6990
for (const field of fields) {
7091
const parts = field.toString().split('=', 2);
7192
if (parts.length == 1) {

0 commit comments

Comments
 (0)