Skip to content

Commit 65157f1

Browse files
authored
Create action.yml
1 parent 9d9398c commit 65157f1

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

action.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: "Check file"
2+
description: "Check file for expected changes."
3+
inputs:
4+
file:
5+
description: "File to search."
6+
required: true
7+
search:
8+
description: "Grep pattern to search."
9+
required: true
10+
runs:
11+
using: composite
12+
steps:
13+
- shell: bash
14+
env:
15+
FILE: ${{ inputs.file }}
16+
SEARCH: ${{ inputs.search }}
17+
run: |
18+
echo "Check that all required env variables are set"
19+
if [ -z "$FILE" ]
20+
then
21+
echo "FILE is unset or set to the empty string"
22+
exit 1
23+
fi
24+
if [ -z "$SEARCH" ]
25+
then
26+
echo "SEARCH is unset or set to the empty string"
27+
exit 1
28+
fi
29+
30+
# Make sure to escape your backslashes => \\ <= in YAML
31+
# So that its still a single \ in bash
32+
33+
echo "Check that $FILE includes $SEARCH"
34+
if grep --extended-regexp "$SEARCH" -- $FILE
35+
then
36+
echo "Found $SEARCH in $FILE"
37+
else
38+
echo "Missing $SEARCH in $FILE"
39+
echo "----------------"
40+
echo "$(cat $FILE)"
41+
exit 204 # We're sending a weird code so it looks different from other "failures"
42+
fi

0 commit comments

Comments
 (0)