dawidd6 / action-download-artifact

:gear: A GitHub Action to download an artifact associated with given workflow and commit or other criteria
MIT License
723 stars 210 forks source link

`name_is_regexp` option doesn't work, name is always a string #309

Closed rschristian closed 2 months ago

rschristian commented 2 months ago

Sorry to raise an issue, but I'm quite baffled to the output I'm seeing.

Despite multiple artifact's names matching the input regexp, somehow, the action finds none are matching.

Run output (also can be found here w/ associated workflow file):

Run dawidd6/action-download-artifact@v2
  with:
    workflow: 5144605
    run_id: 11095106661
    name_is_regexp: true
    name: /results/
    path: results
    github_token: ***
    workflow_conclusion: success
    repo: preactjs/preact
    allow_forks: true
    check_artifacts: false
    search_artifacts: false
    skip_unpack: false
    if_no_artifact_found: fail
==> Repository: preactjs/preact
==> Artifact name: /results/
==> Local path: results
==> Workflow name: 5144605
==> Workflow conclusion: success
==> Allow forks: true
==> (not found) Artifact: /results/
==> Found the following artifacts instead:
    ==> (found) Artifact: npm-package
    ==> (found) Artifact: bench-environment
    ==> (found) Artifact: results-text-update_text-update
    ==> (found) Artifact: results-table-app_update10th1k
    ==> (found) Artifact: results-todo_todo
    ==> (found) Artifact: results-filter-list_filter-list
    ==> (found) Artifact: results-many-updates_many-updates
    ==> (found) Artifact: results-table-app_hydrate1k
    ==> (found) Artifact: results-table-app_create10k
    ==> (found) Artifact: results-table-app_replace1k

Looking into the source, this isn't any clearer:

https://github.com/dawidd6/action-download-artifact/blob/268677152d06ba59fcec7a7f0b5d961b6ccd7e1e/main.js#L182-L194

Assuming the data form is correct, every one of those with results should be in the filtered list, as ('results-table-app_update10th1k'.match(/results/) !== null) == true, but they're not.

Asking in the hopes I'm being daft, or that this makes more sense to you, as I cannot figure out what's going wrong here.

rschristian commented 2 months ago

Tracked it down, name_is_regexp isn't actually taking a regex as input, but a string it can cast using new RegExp(name), which isn't the same.

I can work around it, so closing this out.