Skip to content

Commit

Permalink
WIP post preview comment
Browse files Browse the repository at this point in the history
Signed-off-by: Antoine THEBAUD <[email protected]>
  • Loading branch information
Antoine THEBAUD committed Dec 10, 2024
1 parent 2b6dc4c commit b9b0aac
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions actions/preview_dashboards/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,28 @@ runs:
steps:
- name: Run the `dac preview` command
run: |
percli dac preview \
preview_output=$(percli dac preview \
$([[ -n "${{ inputs.directory }}" ]] && echo "-d ${{ inputs.directory }}") \
$([[ -n "${{ inputs.file }}" ]] && echo "-f ${{ inputs.file }}") \
$([[ -n "${{ inputs.output }}" ]] && echo "-o ${{ inputs.output }}") \
$([[ -n "${{ inputs.prefix }}" ]] && echo "--prefix ${{ inputs.prefix }}") \
$([[ -n "${{ inputs.project }}" ]] && echo "--project ${{ inputs.project }}") \
$([[ -n "${{ inputs.ttl }}" ]] && echo "--ttl ${{ inputs.ttl }}")
$([[ -n "${{ inputs.ttl }}" ]] && echo "--ttl ${{ inputs.ttl }}"))
echo "${preview_output}" > preview_output.json
shell: bash

- name: Post preview links to PR
if: ${{ github.event_name == 'pull_request' }}
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const data = JSON.parse(fs.readFileSync('preview_output.json', 'utf8'));
const previewLinks = data.map(item => `- [${item.Project}/${item.Dashboard}](${item.Preview})`).join('\n');
const commentBody = `### Dashboard Previews\nThe following dashboards have been deployed as previews:\n\n${previewLinks}`;
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: commentBody
});

0 comments on commit b9b0aac

Please sign in to comment.