Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs about the exit code #262

Merged
merged 3 commits into from
Nov 7, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: Update env.exit_code to outputs.exit_code
The previous expression always gives `false`.
Both `env.exit_code` and `env.lychee_exit_code` are `null`, probably since the docker→composite refactor #128. When GitHub evaluates the expression, it finds the types do not match, and coerces them to number, namely, `null` → `0`.

See [Evaluate expressions in workflows and actions - GitHub Docs](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions#operators).

Relates to #253.
YDX-2147483647 committed Nov 5, 2024
commit f484cb59ab948746a269562f11f0e0181dc29aa8
3 changes: 2 additions & 1 deletion .github/workflows/links.yml
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ jobs:
- uses: actions/checkout@v4

- name: Link Checker
id: lychee
uses: ./ # Uses an action in the root directory
with:
args: --user-agent "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0" --verbose --exclude spinroot.com --no-progress './**/*.md' './**/*.html' './**/*.rst'
@@ -23,7 +24,7 @@ jobs:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Create Issue From File
if: env.exit_code != 0
if: ${{ steps.lychee.outputs.exit_code }} != 0
Copy link
Member

@mre mre Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YDX-2147483647, this seems to have led to a false-positive issue creation here: #264

Note that there were no issues with the check run, but it still created the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry… I guess ${{ steps.lychee.outputs.exit_code }} != 0 evaluates to "0 != 0" (a string), and becomes true when GitHub coerces its type.

So it should be if: steps.lychee.outputs.exit_code != 0 or if: ${{ steps.lychee.outputs.exit_code != 0 }}. Not sure, however. I'll test it in my own repo later (in one or two days).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have just tested it, and it works for both success and failure. Please see #265.

uses: peter-evans/create-issue-from-file@v5
with:
title: Link Checker Report
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ jobs:
uses: lycheeverse/lychee-action@v2

- name: Create Issue From File
if: env.exit_code != 0
if: ${{ steps.lychee.outputs.exit_code }} != 0
uses: peter-evans/create-issue-from-file@v5
with:
title: Link Checker Report