action-validator icon indicating copy to clipboard operation
action-validator copied to clipboard

if condition rejected by GitHub not flagged

Open ekohl opened this issue 11 months ago • 1 comments

Want to help get this issue implemented? Donate to the action-validator code fund.


From https://github.com/theforeman/foreman_dhcp_browser/blob/e80fc0e5ffdc1f30ba23ebf3ad9314b456dea06e/.github/workflows/release.yml#L14 there's this bit:

jobs:
  release:
    if: github.repository_owner == "theforeman"

When running it I see

 Invalid workflow file: .github/workflows/release.yml#L14
The workflow is not valid. .github/workflows/release.yml (Line: 14, Col: 9): Unexpected symbol: '"theforeman"'. Located at position 28 within expression: github.repository_owner == "theforeman"

But with action-validator 0.6.0 I see:

$ wget https://github.com/mpalmer/action-validator/releases/download/v0.6.0/action-validator_linux_amd64
$ chmod +x action-validator_linux_amd64
$ ./action-validator_linux_amd64 release.yml
$

I also verified that if I explicitly create an error it is shown.

Reading https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/using-conditions-to-control-job-execution#example-only-run-job-for-specific-repository I see I should have used single quotes:

jobs:
  release:
    if: github.repository_owner == 'theforeman'

ekohl avatar Jan 24 '25 18:01 ekohl

Yeah, we don't do any validation of the contents of fields at present, with the exception of a couple of special cases like paths. A PR implementing such validation would be warmly received.

mpalmer avatar Jan 25 '25 02:01 mpalmer