Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ inputs:
scan-for-text:
description: "Specify the string that has to be scanned"
required: true
insecure:
description: "Set to true to disable TSL certificate checking"
default: false
runs:
using: "composite"
steps:
- run: echo Scanning ${{ inputs.web-url }} for string ${{ inputs.scan-for-text }}
shell: bash
- run: chmod +x ${{ github.action_path }}/scan-website.sh
shell: bash
- run: ${{ github.action_path }}/scan-website.sh ${{ inputs.web-url }} ${{ inputs.scan-for-text }}
- run: ${{ github.action_path }}/scan-website.sh ${{ inputs.insecure }} ${{ inputs.web-url }} ${{ inputs.scan-for-text }}
shell: bash
20 changes: 16 additions & 4 deletions scan-website.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
website_url=$1
scan_text=$2
status_code=$(curl --silent --location --head --output /dev/null --write-out "%{http_code}" "${website_url}")
insecure=$1
website_url=$2
scan_text=$3

curl_options="--silent --location --head --output /dev/null --write-out %{http_code}"
if [ $insecure == "true" ]; then
curl_options="--insecure ${curl_options}"
fi

status_code=$(curl ${curl_options} "${website_url}")

if [ "${status_code}" != "200" ]; then
echo "Website is unreachable (${status_code})" >&2
exit 1
fi

if ! curl --silent --location "{$website_url}" | grep --quiet --ignore-case "${scan_text}"; then
curl_options="--silent --location"
if [ $insecure == "true" ]; then
curl_options="--insecure ${curl_options}"
fi

if ! curl ${curl_options} "{$website_url}" | grep --quiet --ignore-case "${scan_text}"; then
echo "Text was not found on website" >&2
exit 1
fi
Expand Down