diff --git a/README.md b/README.md index 5ffe96e..1f7f964 100644 --- a/README.md +++ b/README.md @@ -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
diff --git a/action.yml b/action.yml index 40d4f01..ee0cc91 100644 --- a/action.yml +++ b/action.yml @@ -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 @@ -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') @@ -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: