diff --git a/README.md b/README.md index 092ad3ca..ee5522a2 100644 --- a/README.md +++ b/README.md @@ -359,7 +359,7 @@ tags: | Will be used on [schedule event](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#schedule). -`pattern` is a specially crafted attribute to support [Handlebars template](https://handlebarsjs.com/guide/) with +`pattern` is a specially crafted attribute to support [Handlebars' template](https://handlebarsjs.com/guide/) with the following expressions: * `date 'format'` ; render date by its [moment format](https://momentjs.com/docs/#/displaying/format/) @@ -478,7 +478,7 @@ tags: | ``` Can create a regular expression for matching Git tag with a pattern and capturing group. Will be used on a -[push tag event](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#push) but you can also use +[push tag event](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#push) but, you can also use a custom value through `value` attribute. | Git tag | Pattern | Group | Output | @@ -615,7 +615,7 @@ tags: | ### Global expressions -The following [Handlebars template](https://handlebarsjs.com/guide/) expressions for `prefix`, `suffix` and `value` +The following [Handlebars' template](https://handlebarsjs.com/guide/) expressions for `prefix`, `suffix` and `value` attributes are available: | Expression | Output | @@ -679,7 +679,7 @@ workflow using the [`fromJSON` function](https://docs.github.com/en/actions/lear ### Overwrite labels -If some of the [OCI Image Format Specification](https://github.com/opencontainers/image-spec/blob/master/annotations.md) +If some [OCI Image Format Specification](https://github.com/opencontainers/image-spec/blob/master/annotations.md) labels generated are not suitable, you can overwrite them like this: ```yaml diff --git a/__tests__/context.test.ts b/__tests__/context.test.ts index 89fca489..52fcd122 100644 --- a/__tests__/context.test.ts +++ b/__tests__/context.test.ts @@ -15,55 +15,61 @@ jest.spyOn(context, 'tmpDir').mockImplementation((): string => { describe('getInputList', () => { it('single line correctly', async () => { await setInput('foo', 'bar'); - const res = await context.getInputList('foo'); + const res = context.getInputList('foo'); expect(res).toEqual(['bar']); }); it('multiline correctly', async () => { setInput('foo', 'bar\nbaz'); - const res = await context.getInputList('foo'); + const res = context.getInputList('foo'); expect(res).toEqual(['bar', 'baz']); }); it('empty lines correctly', async () => { setInput('foo', 'bar\n\nbaz'); - const res = await context.getInputList('foo'); + const res = context.getInputList('foo'); expect(res).toEqual(['bar', 'baz']); }); + it('comment correctly', async () => { + setInput('foo', 'bar\n#com\n"#taken"\nhello#comment\nbaz'); + const res = context.getInputList('foo'); + expect(res).toEqual(['bar', '#taken', 'hello', 'baz']); + }); + it('comma correctly', async () => { setInput('foo', 'bar,baz'); - const res = await context.getInputList('foo'); + const res = context.getInputList('foo'); expect(res).toEqual(['bar', 'baz']); }); it('empty result correctly', async () => { setInput('foo', 'bar,baz,'); - const res = await context.getInputList('foo'); + const res = context.getInputList('foo'); expect(res).toEqual(['bar', 'baz']); }); it('different new lines correctly', async () => { setInput('foo', 'bar\r\nbaz'); - const res = await context.getInputList('foo'); + const res = context.getInputList('foo'); expect(res).toEqual(['bar', 'baz']); }); it('different new lines and comma correctly', async () => { setInput('foo', 'bar\r\nbaz,bat'); - const res = await context.getInputList('foo'); + const res = context.getInputList('foo'); expect(res).toEqual(['bar', 'baz', 'bat']); }); it('multiline and ignoring comma correctly', async () => { setInput('cache-from', 'user/app:cache\ntype=local,src=path/to/dir'); - const res = await context.getInputList('cache-from', true); + const res = context.getInputList('cache-from', true); expect(res).toEqual(['user/app:cache', 'type=local,src=path/to/dir']); }); it('different new lines and ignoring comma correctly', async () => { setInput('cache-from', 'user/app:cache\r\ntype=local,src=path/to/dir'); - const res = await context.getInputList('cache-from', true); + const res = context.getInputList('cache-from', true); expect(res).toEqual(['user/app:cache', 'type=local,src=path/to/dir']); }); @@ -76,7 +82,7 @@ bbbbbbb ccccccccc" FOO=bar` ); - const res = await context.getInputList('secrets', true); + const res = context.getInputList('secrets', true); expect(res).toEqual([ 'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789', `MYSECRET=aaaaaaaa @@ -99,7 +105,7 @@ FOO=bar bbbb ccc"` ); - const res = await context.getInputList('secrets', true); + const res = context.getInputList('secrets', true); expect(res).toEqual([ 'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789', `MYSECRET=aaaaaaaa @@ -122,7 +128,7 @@ bbbbbbb ccccccccc FOO=bar` ); - const res = await context.getInputList('secrets', true); + const res = context.getInputList('secrets', true); expect(res).toEqual(['GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789', 'MYSECRET=aaaaaaaa', 'bbbbbbb', 'ccccccccc', 'FOO=bar']); }); @@ -135,7 +141,7 @@ bbbb""bbb ccccccccc" FOO=bar` ); - const res = await context.getInputList('secrets', true); + const res = context.getInputList('secrets', true); expect(res).toEqual([ 'GIT_AUTH_TOKEN=abcdefgh,ijklmno=0123456789', `MYSECRET=aaaaaaaa diff --git a/dist/index.js b/dist/index.js index 81fa0571..b76b82d0 100644 --- a/dist/index.js +++ b/dist/index.js @@ -75,6 +75,7 @@ function getInputList(name, ignoreComma) { for (let output of sync_1.default(items, { columns: false, relax: true, + comment: '#', relaxColumnCount: true, skipLinesWithEmptyValues: true })) { diff --git a/src/context.ts b/src/context.ts index 4fd5e547..7bde054e 100644 --- a/src/context.ts +++ b/src/context.ts @@ -49,6 +49,7 @@ export function getInputList(name: string, ignoreComma?: boolean): string[] { for (let output of csvparse(items, { columns: false, relax: true, + comment: '#', relaxColumnCount: true, skipLinesWithEmptyValues: true }) as Array) {