cortex-rules-action icon indicating copy to clipboard operation
cortex-rules-action copied to clipboard

fix: multiline output

Open rasta-rocket opened this issue 1 year ago • 3 comments

Hey folks 👋

Small PR that fix/simplify the way the multiline is rendered in the output of the action

With the following pipeline

name: loki_rules_ci
on:
  workflow_dispatch:
  pull_request:
jobs:
  loki_rules:
    name: Check Loki Rules
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Check Loki rules
        uses: rasta-rocket/cortex-rules-action@fix_multiline
        env:
          CORTEX_ADDRESS: "xxxxxx"
          CORTEX_TENANT_ID: xxxxx
          BACKEND: loki
          ACTION: check
          RULES_DIR: "./loki/alert,./loki/record"
      - name: Diff Loki rules
        id: diff_rules
        uses: rasta-rocket/cortex-rules-action@fix_multiline
        env:
          CORTEX_ADDRESS: "xxxxxxx"
          CORTEX_TENANT_ID: xxxxx
          BACKEND: loki
          ACTION: diff
          RULES_DIR: "./loki/alert,./loki/record"
      - name: Put diff in summary
        run: |
           echo "${{ steps.diff_rules.outputs.detailed }}"

           echo '# Diff summary' >> $GITHUB_STEP_SUMMARY
           echo '```diff' >> $GITHUB_STEP_SUMMARY
           echo "${{ steps.diff_rules.outputs.detailed }}" >> $GITHUB_STEP_SUMMARY
           echo '```' >> $GITHUB_STEP_SUMMARY

Before the fix: image

After the fix: image

This has been done following :

  • https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-of-a-multiline-string
  • https://til.juliusgamanyi.com/posts/gh-actions-save-multiline-string-in-output-var/

Don't hesitate to ping me if any remarks/questions 😉 ?

Cheers ☀️

rasta-rocket avatar Jul 10 '24 18:07 rasta-rocket

A couple of requests, please:

  1. Could you provide an example that shows the issue you're fixing, please?
  2. Can you check the CI linter failure, please?

pracucci avatar Jul 11 '24 14:07 pracucci

@pracucci thx for the first review 😉

  1. I updated the main description of the PR with screenshot
  2. I fixed the linting according the CI recommendation

rasta-rocket avatar Jul 12 '24 13:07 rasta-rocket

@pracucci 👋 did you had a chance to review my last changes ?

rasta-rocket avatar Aug 12 '24 16:08 rasta-rocket

LGTM, thank you.

colega avatar Dec 24 '24 11:12 colega