This GitHub Action allows you to compare two files based on a tolerance, output the result to a file and send various notifications (comment on a linked GitHub issue/pull request, create a Check Run, ...), etc.
The following shows how to compare two files, making sure only additions happened, and output the difference to a file.
name: "build-test"
on: [push]
jobs:
test_something:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Check that the files are the exact same
uses: LouisBrunner/[email protected]
with:
old: file1.txt
new: file2.txt
mode: strict
tolerance: same
output: out1.txt
- name: Check that there are only additions in file2.txt
uses: LouisBrunner/[email protected]
with:
old: file1.txt
new: file2.txt
mode: addition
tolerance: better
output: out2.txt
See the examples workflow for more details and examples (and see the associated runs to see how it will look like).
Required The first file to compare
Required The second file to compare
Optional The method used to measure the tolerance
, can be either:
strict
(default): the files must be exactly the same, onlytolerance: same
is allowed (which is the default)addition
: addition are betterdeletion
: deletion are better
Optional The tolerance to check the diff for, depends on mode
, can be either (examples given with mode = deletion
) better
(only deletion), mixed-better
(more deletion than addition), same
(stay the exact same), mixed
(same amount of lines but not the same), mixed-worse
(more addition than deletion) or worse
(only addition)
Default is same
Optional The path where to output the diff (as well as on the console)
Optional Your GITHUB_TOKEN
, required when using notify_check
and/or notify_issue
Optional add a title to the notifications to distinguish between multiple workflows/jobs
Optional Will create a GitHub Check Run if 'true'
is specified, requires token
to be given as well
Optional Will create a comment in the linked issue if specified, requires token
to be given as well.
Possible values:
always
/true
: will always create a comment (note:true
is deprecated in favor ofalways
)failure
: will only create a comment if the check failssuccess
: will only create a comment if the check passes
Optional When using notify_issue: true
, will edit the created comment instead of creating a new one everytime.
Note that the updated comment is based on the title
. Thus:
- if you call the action multiple times in your workflow, make sure the titles are unique to each call to avoid overwriting the same comment
- make sure the titles are the same between different calls to the action if you want to update the same comment
Contains a boolean ('true'
or 'false'
) representing if the check passed or not
Contains the output of the diff