Skip to content

Commit

Permalink
Improve test-external-links (#1463)
Browse files Browse the repository at this point in the history
The action should:
- only post a Slack message on a scheduled failure - a manually
triggered run will _already_ notify the initiator via email of the
action failure, and is probably only being done for debugging purposes
anyway.

- more gracefully handle the unicode issue addressed in
#1462 so that it doesn't crash
(but exact behaviour irrelevant as long as _an_ error is logged)
  • Loading branch information
JackPGreen authored Jan 15, 2025
1 parent f55a36b commit c9eacc1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .github/actions/test-external-links/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ runs:
fi

if [[ "${status}" -eq 404 ]]; then
locations=$(grep -rl "${url}")
# In the event of unicode control characters, grep's behaviour may be unpredictable - but lets not fail the workflow for that
locations=$(grep -rl "${url}" || true)
echo "::error::❌ URL '${url}' had status ${status} (found in ${locations})" 1>&2
found_error=1
else
Expand All @@ -85,7 +86,7 @@ runs:

- name: Slack notification
uses: 8398a7/action-slack@v3
if: failure()
if: failure() && github.event_name == 'schedule'
with:
status: failure
fields: repo,job,workflow
Expand Down

0 comments on commit c9eacc1

Please sign in to comment.