Skip to content

Commit cccbf14

Browse files
authored
Allow promotes to include named links (#65)
The text and URL of the link come from a provided template file. For now, the only variable that can be passed to the template is docker-image-sha256-63. (We have designed this specifically so that database migration promotions can link to GCP logs for a k8s job that ran `flyway info`.)
1 parent 6ea14ba commit cccbf14

File tree

8 files changed

+418
-7
lines changed

8 files changed

+418
-7
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
link-one:
2+
text:
3+
- literal: 'Link to '
4+
- variable: foo
5+
url:
6+
- literal: 'https://some-site.example/logs/query?foo='
7+
- variable: 'foo'
8+
- literal: '&bar=yay'

__tests__/templates.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { join } from 'path';
2+
import { readLinkTemplateMapFile, renderLinkTemplate } from '../src/templates';
3+
4+
function fixtureFilename(filename: string): string {
5+
return join(__dirname, '__fixtures__', 'templates', filename);
6+
}
7+
8+
describe('templates', () => {
9+
it('renders a template', async () => {
10+
const templateMap = await readLinkTemplateMapFile(
11+
fixtureFilename('templates.yaml'),
12+
);
13+
expect(
14+
renderLinkTemplate(
15+
templateMap,
16+
'link-one',
17+
new Map([
18+
['foo', 'hooray'],
19+
['bla', 'another'],
20+
]),
21+
),
22+
).toStrictEqual({
23+
text: 'Link to hooray',
24+
url: 'https://some-site.example/logs/query?foo=hooray&bar=yay',
25+
});
26+
});
27+
});

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ inputs:
4242
generate-promoted-commits-markdown:
4343
description: 'Generates the promoted-commits-markdown output'
4444
default: 'false'
45+
46+
link-template-file:
47+
description: 'If provided, a path to a YAML file mapping from template names to link templates. A template is a `text` and an `url`, each of which is a list of objects, each of which is of the form `{literal: "literal text"}` or `{variable: "variable-name"}.'
4548

4649
outputs:
4750
suggested-promotion-branch-name:

dist/index.js

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

0 commit comments

Comments
 (0)