-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
68 lines (61 loc) · 2.12 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: 'DIFF Action 🕵️'
description: 'Github Action to compare 2 files using diff 🕵️'
inputs:
first_file_path:
description: 'repo/path/file.txt'
required: true
second_file_path:
description: 'repo/path/file.txt'
required: true
expected_result:
description: 'PASSED or FAILED'
required: false
default: 'PASSED'
specific_line:
description: 'file line to compare'
required: false
outputs:
diff-output:
description: "Diff output"
value: ${{ steps.diff.outputs.result }}
runs:
using: "composite"
steps:
- id: diff
run: |
if [ -z ${{ inputs.specific_line }} ]; then
echo Comparing files
if diff ${{ inputs.first_file_path }} ${{ inputs.second_file_path }} >/dev/null; then
result=$(echo "PASSED")
else
result=$(echo "FAILED")
fi
else
echo Comparing files specific line
if diff <(head -n ${{ inputs.specific_line }} ${{ inputs.first_file_path }}) <(head -n ${{ inputs.specific_line }} ${{ inputs.second_file_path }} ) >/dev/null; then
result=$(echo "PASSED")
else
result=$(echo "FAILED")
fi
fi
echo ↔️ DIFF command result is $result
echo "::set-output name=result::$(echo $result)"
shell: bash
- run: |
echo ➡️ OUTPUT value is ${{ steps.diff.outputs.result }}
echo ➡️ EXPECTED value is ${{ inputs.expected_result }}
if [ ${{ steps.diff.outputs.result }} != ${{ inputs.expected_result }} ]; then
echo "❌ OUTPUT value NOT EQUAL to EXPECTED value!"
if [ -z ${{ inputs.specific_line }} ]; then
diff ${{ inputs.first_file_path }} ${{ inputs.second_file_path }}
else
diff <(head -n ${{ inputs.specific_line }} ${{ inputs.first_file_path }}) <(head -n ${{ inputs.specific_line }} ${{ inputs.second_file_path }} )
fi
exit 1
else
echo "✅ OUTPUT value EQUAL to EXPECTED value!"
fi
shell: bash
branding:
icon: 'check'
color: 'blue'