Skip to content

Commit b9b0aac

Browse files
author
Antoine THEBAUD
committed
WIP post preview comment
Signed-off-by: Antoine THEBAUD <[email protected]>
1 parent 2b6dc4c commit b9b0aac

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

actions/preview_dashboards/action.yaml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,28 @@ runs:
2626
steps:
2727
- name: Run the `dac preview` command
2828
run: |
29-
percli dac preview \
29+
preview_output=$(percli dac preview \
3030
$([[ -n "${{ inputs.directory }}" ]] && echo "-d ${{ inputs.directory }}") \
3131
$([[ -n "${{ inputs.file }}" ]] && echo "-f ${{ inputs.file }}") \
3232
$([[ -n "${{ inputs.output }}" ]] && echo "-o ${{ inputs.output }}") \
3333
$([[ -n "${{ inputs.prefix }}" ]] && echo "--prefix ${{ inputs.prefix }}") \
3434
$([[ -n "${{ inputs.project }}" ]] && echo "--project ${{ inputs.project }}") \
35-
$([[ -n "${{ inputs.ttl }}" ]] && echo "--ttl ${{ inputs.ttl }}")
35+
$([[ -n "${{ inputs.ttl }}" ]] && echo "--ttl ${{ inputs.ttl }}"))
36+
echo "${preview_output}" > preview_output.json
3637
shell: bash
38+
39+
- name: Post preview links to PR
40+
if: ${{ github.event_name == 'pull_request' }}
41+
uses: actions/github-script@v6
42+
with:
43+
script: |
44+
const fs = require('fs');
45+
const data = JSON.parse(fs.readFileSync('preview_output.json', 'utf8'));
46+
const previewLinks = data.map(item => `- [${item.Project}/${item.Dashboard}](${item.Preview})`).join('\n');
47+
const commentBody = `### Dashboard Previews\nThe following dashboards have been deployed as previews:\n\n${previewLinks}`;
48+
github.rest.issues.createComment({
49+
owner: context.repo.owner,
50+
repo: context.repo.repo,
51+
issue_number: context.issue.number,
52+
body: commentBody
53+
});

0 commit comments

Comments
 (0)