Skip to content

Commit

Permalink
Add additional flag to failOnError
Browse files Browse the repository at this point in the history
Bump NSP rustic version to `v0.1.7`
Set `debug` flag based on GH actions'
Write the errors output to `GITHUB_STEP_SUMMARY`
Exit based on the errors output file
  • Loading branch information
dormant-user committed May 14, 2024
1 parent b955f9c commit d3624cb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ jobs:
Use the options below to configure debug and fail state when broken links are found in the repository/wiki pages.
| option | requirement | description |
|--------------------|-------------|---------------------------------------------------------------------------|
| `debug` | optional | If `true` (Default is `false`) debug level logging is enabled |
| `owner` | optional | Owner/Organization of the repository - Defaults to current owner/org name |
| `repo` | optional | Name of the repository - Defaults to current repository's name |
| `excludeHostnames` | optional | Space separated list of hostnames to ignore when failed |
- `debug` - If `true` debug level logging is enabled. _Defaults to `false`_
- `owner` - Owner/Organization of the repository. _Defaults to current owner/org name_
- `repo` - Name of the repository. _Defaults to current repository's name_
- `excludeHostnames` - Space separated list of hostnames to ignore when failed. _Defaults to `""`_
- `failOnError` - If `true` (Default is `false`) the action will fail if broken links are found. _Defaults to `false`_

> `excludeHostnames` will perform a regex like lookup, so wildcards (*) are not required<br>

Expand Down
35 changes: 33 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ inputs:
description: Hostnames for which the failure should be ignored
required: false
default: ""
failOnError:
description: Fail the action if any hyperlinks are broken
required: false
default: "false"
outputs: {}
runs:
using: composite
Expand All @@ -28,7 +32,7 @@ runs:

- name: Download Asset
run: |
response=$(curl -sL "https://api.github.com/repos/thevickypedia/none-shall-pass-rustic/releases/tags/v0.1.6")
response=$(curl -sL "https://api.github.com/repos/thevickypedia/none-shall-pass-rustic/releases/tags/v0.1.7")
release_id=$(echo "$response" | jq -r '.id')
tag_name=$(echo "$response" | jq -r '.tag_name')
published_at=$(echo "$response" | jq -r '.published_at')
Expand All @@ -42,7 +46,34 @@ runs:
shell: bash

- name: Run Asset
run: ./asset --debug ${{ inputs.debug }} --owner ${{ inputs.owner }} --repo ${{ inputs.repo }} --exclude "${{ inputs.excludeHostnames }}"
run: |
debug="false"
if [[ ${{ inputs.debug }} == true || ${{ env.RUNNER_DEBUG }} == 1 ]]; then
debug="true"
fi
./asset --debug "$debug" --owner "${{ inputs.owner }}" --repo "${{ inputs.repo }}" --exclude "${{ inputs.excludeHostnames }}"
shell: bash

- name: Summary
run: |
if [ -f "GH_ACTIONS_SUMMARY" ]; then
echo "::error title=Failed hyperlinks::Following hyperlinks are broken."
while IFS= read -r line || [[ -n "$line" ]]; do
echo "$line" >> $GITHUB_STEP_SUMMARY
done < "GH_ACTIONS_SUMMARY"
else
echo "::notice title=Successful Run::No broken hyperlinks found."
fi
shell: bash

- name: Exit Code
if: inputs.failOnError == 'true'
run: |
if [ -f "GH_ACTIONS_SUMMARY" ]; then
exit 1
else
exit 0
fi
shell: bash

branding:
Expand Down

0 comments on commit d3624cb

Please sign in to comment.