A Github action to differentiate 2 JSON strings, and post a comment on the PR with the diff. If you are using this action outside of a PR it will only log the diff.
string_a: Compare this stringstring_b: With this stringgithub_token: A github token, to get the contextheader_text: An optional text to print as header on the comment
result: The result of the diff, if no diff found it will be an empty string.
name: Pull Request differentiate JSONs
on: [pull_request]
jobs:
test:
runs-on: ubuntu-latest
name: Differentiate
steps:
- uses: actions/checkout@v2
- name: Read file A
id: readfile_a
run: echo "::set-output name=content::$(jq -c . ./file_a.json)"
- name: Read file B
id: readfile_b
run: echo "::set-output name=content::$(jq -c . ./file_b.json)"
- name: "PR Comment"
uses: pmckl/action-json-diff@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
string_a: "${{ steps.readfile_a.outputs.content }}"
string_b: "${{ steps.readfile_b.outputs.content }}"
header_text: "Diff for file_a.json and file_b.json"