Interpolating an expression in GitHub Action

Viewed 585

I'm using the mshick/add-pr-comment GitHub action which sends a message to a PR.

Instead of sending a static text (like in the example), I need to have a dynamic message which is the result of the following expression: cat rs/coverage/.last_run.json | jq '.result.line'

How can I interpolate such an expression?

I have tried but it sends the exact string and not the result of it.

- uses: mshick/add-pr-comment@v1
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
   with:
     message: $(cat reaction6/coverage/.last_run.json | jq '.result.line')
1 Answers

Please try first set vairable and then use it:

- name: Create PR message
  run: echo "msg=$(cat reaction6/coverage/.last_run.json | jq '.result.line')" >> $GITHUB_ENV
- uses: mshick/add-pr-comment@v1
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
   with:
     message: "${{ env.msg}}"

Related