JasonEtco/upload-to-release

Workflow question

Closed this issue · 4 comments

Do I understand correctly that you can create a file artifact in one Action of the workflow and it's preserved and available in the containers of subsequent Actions?

Hey @webknjaz - yep, that's correct, Actions in a workflow effectively share a file system for two folders: /github/home and /github/workspace, using $HOME and $GITHUB_WORKSPACE. You can read more about that here: https://developer.github.com/actions/creating-github-actions/accessing-the-runtime-environment/#filesystem

Hope that answers your question!

Ah.. I probably missed that!

An action can modify the contents of this directory, which subsequent actions can access.

@JasonEtco what happens when there are two parallel actions mutating the files and then next one depends on both of them? Wouldn't be there some sort of collision?

As in

      A1
    /    \
   /      \
 A21      A22
   \      /
    \    /
      A3

I suppose that A1 can create file X, then it will be accessible by A21 and A22, they both change this file, so which version will A3 see?

That's a good question - I'm not sure! I'd guess that yes, collision can occur - it's two processes writing to a file in parallel. So you'd need to namespace files, or make sure that some kind of buffering is in place to prevent parallel writes. I'd say that as a general rule, if you're mutating multiple files (not just one namespaced file), you're better off designing your workflow to work in sequence rather than in parallel.

Oh, I didn't realize that the fs is mounted simultaneously. I thought that maybe artifacts are copied...