File tree Expand file tree Collapse file tree 2 files changed +20
-11
lines changed
actions/preview_dashboards Expand file tree Collapse file tree 2 files changed +20
-11
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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
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+ });
You can’t perform that action at this time.
0 commit comments