Access to path denied during artifact upload

I have a docs build action for PHPMailer that passes artifacts between two jobs in a single workflow, but it’s failing with this error:

Uploading artifact 'docs' from '/home/runner/work/PHPMailer/PHPMailer/docs' for run #3
##[error]Access to the path '/home/runner/work/PHPMailer/PHPMailer/docs/phpdoc-cache-8b' is denied.
##[error]Exit code 1 returned from process: file name '/home/runner/runners/2.158.0/bin/Runner.PluginHost', arguments 'action "GitHub.Runner.Plugins.Artifact.PublishArtifact, Runner.Plugins"'.

As far as I can see I’ve followed what  the docs say - so why don’t I have access to this path?

In the case of actions that use a Dockerfile those files are probably created as the root user inside the container.  Because the upload-artifact action runs as the runner user you will need to sudo chmod the permissions on those files so the runner user can read them.

I attempted to chmod the path that it was complaining about, but it said it didn’t exist!

A solution was found by merging the build and publish steps into one job, so that it didn’t need to use the upload/download steps at all.