download-artifact icon indicating copy to clipboard operation
download-artifact copied to clipboard

support for "workflow_run" event triggers

Open jkowalleck opened this issue 4 years ago • 9 comments

the support for the newly introduced event "worgkflow_run" for github actions seams broken.

see my test environment: https://github.com/jkowalleck/playground_workflow_run

playground_workflow_run

playground for github event "worgkflow_run".

For example, if your pull_request workflow generates build artifacts, you can create a new workflow that uses workflow_run to analyze the results and add a comment to the original pull request.

The goal of tis playground is to see if downloading and processing artifacts in a "worgkflow_run" eent works as expected.

expectation

in a "worgkflow_run" triggered event i can download artifacts from the workflow that triggered the "worgkflow_run" trigger.

conclusion

the action "download-artifact" semas to be broken on event "worgkflow_run".

obeservations

how i tested

  1. action "TESTS" is triggered on push.
    • it creates an artifact "reports".
    • it downloads that exact sams artifact "reports".
  2. action "TESTS DONE" is triggered after the action "TESTS" completed.
    • it downloads that exact sams artifact "reports" from the "TESTS" action.

jkowalleck avatar Aug 23 '20 12:08 jkowalleck

why i expected the download to word with "workflow_run" events:

  • my workflow_run debug
    • showed github.event_name as "workflow_run"
    • showed github.event.workflow_run.artifacts_url as "https://api.github.com/repos/jkowalleck/playground_workflow_run/actions/runs/220718887/artifact"

so i thought all needed info was available

jkowalleck avatar Aug 23 '20 12:08 jkowalleck

I think I just encountered this. I have a pull_request workflow that uploads the artifact, and as recommended by https://securitylab.github.com/research/github-actions-preventing-pwn-requests , I am using workflow_run to download it, but I encountered this error:

Error: Unable to find any artifacts for the associated workflow

Luckily the article has code to download using github-script, though it would have been so elegant to just use this action. I'll be interested to revisit this action when this is supported. Thank you!

pllim avatar Jan 12 '21 23:01 pllim

Yeah, this not working properly is a major WTF. I mean come on, having to paste non-trivial code into my revision (from that blog post) is ridiculous. Especially since I'll have to repeat that in every repo...

ThiefMaster avatar Jan 18 '21 01:01 ThiefMaster

Any progress on this?

laeubi avatar Jan 18 '23 07:01 laeubi

https://github.com/actions/download-artifact#download-artifacts-from-other-workflow-runs-or-repositories does most of this, just doesn't automagically pass through the run-id

t3chguy avatar Jan 17 '24 09:01 t3chguy

just doesn't automagically pass through the run-id

Isn't that available?:

run_id: ${{ github.event.workflow_run.id }}

I haven't verified, but adapted the workflow from dawidd6/action-download-artifact@v3 to actions/download-artifact@v4 and expect that to work fine.

polarathene avatar Jan 27 '24 00:01 polarathene

Yes. That indeed has worked for me @polarathene - One unexpected catch was needing to pass a github token with additional permissions, which is unexpected because the @dawidd6 action can get by without a PAT for accessing workflow run artifacts in the same repo.

t3chguy avatar Jan 27 '24 00:01 t3chguy

One unexpected catch was needing to pass a github token with additional permissions, which is unexpected

Oh? In dawidd6/action-download-artifact@v3 I had provided the token as well as I think that was required for what I was doing 🤔 (PR branch workflow triggers a master branch workflow)

I did see the docs for actions/download-artifact@v4 state a workflow_run reference will require a token with access:read permissions, which in my case (same repo, just different branches) that should be fine.

polarathene avatar Jan 27 '24 00:01 polarathene

(PR branch workflow triggers a master branch workflow)

This is what I am using it for too, but I did not pass any token to action-download-artifact e.g. https://github.com/matrix-org/matrix-react-sdk/commit/1dbcdfb6b29036798be348dc05fccda90121e66a yet ultimately had to specify a PAT to retain the same function using the 1st party action - https://github.com/matrix-org/matrix-react-sdk/commit/0d2253e7d04ba173e7d8d05b299404af93e92368

t3chguy avatar Jan 27 '24 00:01 t3chguy