First time using Workflows so bear with me a little.
I’m creating a callable workflow that downloads the source of one of my dependencies and then builds it on a GitHub hosted runner. The build takes a long time, and the resultant binaries sometimes are useful to have for other systems so I’m configuring the last job in the workflow to upload an artifact containing the final install directory. This way, I can download it (via actions/download-artifact) from the caller workflow and use it to build my projects source, as well as grab the artifact from github.com for later use.
The issue here is that it obviously makes no sense to download and build the dependency source if the artifact is already available, so I’d to first check if the artifact already exists (having been put there by actions/upload-artifact) so that everything else can be skipped if so. I’d prefer this check to be part of this workflow (the callee) so that it still “runs” and just largely does nothing if the artifact is already there, so that it’s sort of a “make sure this dependency is available workflow” either way; however, I’d ultimately be fine if the check happened in the caller workflow, which ever way I can do this correctly.
The download-artifact and upload-artifact actions are nice a simple, just provide a name and a path, and so it almost feels like there’s a hole here for a third one that lets you check them in a straightforward manner.
- I’d try just downloading the artifact to see what happens, but from what I understand if it doesn’t exist then the workflow/job will be marked as failed, and regardless the artifact will be ~7GB so that would be a huge waste of time
- I’d use the cache action, since it largely does what I want (since it reports cache hit/miss), but then I can’t casually download the artifact myself for later, and more importantly I need the artifact to persist potentially unaccessed for way longer than 1 week (giving up on the artifact being readily available and making a BS task to just touch the cache every week seems crazy, not to mention clearing cache variables manually, i.e. in the event a build “succeeds” but has issue, isn’t possible at the moment).
- I know you can use the REST API to get a list of all artifacts in a repo, but this seems like it would be really roundabout and a touch hacky, plus I have no idea how I’d do a REST query and parse the list to see if an artifact with ‘name’ exists within a GitHub workflow. I have a feeling that even if it is possible it would be really clunky and potentially unreliable in the long term
- I searched through the official GitHub actions and the marketplace and couldn’t find anything useful other than maybe this, but it only goes part way and has the same “parse a bunch of stuff within a workflow” issue.
So tl;dr, I need something as close to
if: repo.artifacts.contains(NAME) or
if: hasArtifact(NAME) as possible, basically along the same lines as the upload/download artifact actions.
Any idea how I can do this?