@@ -26,11 +26,28 @@ runs:
26
26
steps :
27
27
- name : Run the `dac preview` command
28
28
run : |
29
- percli dac preview \
29
+ preview_output=$( percli dac preview \
30
30
$([[ -n "${{ inputs.directory }}" ]] && echo "-d ${{ inputs.directory }}") \
31
31
$([[ -n "${{ inputs.file }}" ]] && echo "-f ${{ inputs.file }}") \
32
32
$([[ -n "${{ inputs.output }}" ]] && echo "-o ${{ inputs.output }}") \
33
33
$([[ -n "${{ inputs.prefix }}" ]] && echo "--prefix ${{ inputs.prefix }}") \
34
34
$([[ -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
36
37
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