Skip to content

Commit 7ff59d2

Browse files
author
Antoine THEBAUD
committed
WIP post preview comment (+ remove configurable output format)
Signed-off-by: Antoine THEBAUD <[email protected]>
1 parent 2b6dc4c commit 7ff59d2

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

.github/workflows/dac.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,7 @@ on:
6767
type: boolean
6868
required: false
6969
# preview-specific:
70-
output:
71-
description: "Format of the output: json or yaml (default is yaml)."
72-
type: string
73-
required: false
74-
prefix:
70+
prefix: # TODO should be replaced by automatic passing of PR number
7571
description: If provided, it is used to prefix the dashboard preview name.
7672
type: string
7773
required: false
@@ -133,7 +129,6 @@ jobs:
133129
with:
134130
directory: ./built
135131
project: ${{ inputs.project }}
136-
output: ${{ inputs.output }}
137132
prefix: ${{ inputs.prefix }}
138133
ttl: ${{ inputs.ttl }}
139134

actions/preview_dashboards/action.yaml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ inputs:
99
file:
1010
description: Path to the file that contains the resources consumed by the command (mutually exclusive with `directory`).
1111
required: false
12-
output:
13-
description: "Format of the output: json or yaml (default is yaml)."
14-
required: false
1512
prefix:
1613
description: If provided, it is used to prefix the dashboard preview name.
1714
required: false
@@ -29,8 +26,25 @@ runs:
2926
percli dac preview \
3027
$([[ -n "${{ inputs.directory }}" ]] && echo "-d ${{ inputs.directory }}") \
3128
$([[ -n "${{ inputs.file }}" ]] && echo "-f ${{ inputs.file }}") \
32-
$([[ -n "${{ inputs.output }}" ]] && echo "-o ${{ inputs.output }}") \
3329
$([[ -n "${{ inputs.prefix }}" ]] && echo "--prefix ${{ inputs.prefix }}") \
3430
$([[ -n "${{ inputs.project }}" ]] && echo "--project ${{ inputs.project }}") \
35-
$([[ -n "${{ inputs.ttl }}" ]] && echo "--ttl ${{ inputs.ttl }}")
31+
$([[ -n "${{ inputs.ttl }}" ]] && echo "--ttl ${{ inputs.ttl }}") \
32+
-o json \
33+
> preview_output.json
3634
shell: bash
35+
36+
- name: Post preview links to PR
37+
if: ${{ github.event_name == 'pull_request' }}
38+
uses: actions/github-script@v6
39+
with:
40+
script: |
41+
const fs = require('fs');
42+
const data = JSON.parse(fs.readFileSync('preview_output.json', 'utf8'));
43+
const previewLinks = data.map(item => `- [${item.project}/${item.dashboard}](${item.preview})`).join('\n');
44+
const commentBody = `### Dashboard Previews\nThe following dashboards have been deployed as previews:\n\n${previewLinks}`;
45+
github.rest.issues.createComment({
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
issue_number: context.issue.number,
49+
body: commentBody
50+
});

0 commit comments

Comments
 (0)