#Why Does This Happen?
While running a file from a GitHub action, the "Permission denied" error, like the following, can happen when the file you are trying to execute does not have execution permissions:
Run script.sh
/home/runner/work/_temp/18c42cc9-15d4-4159-8fc8-40abfbb37dac.sh: line 1: script.sh: Permission denied
Error: Process completed with exit code 126.
An example workflow yml file that potentially causes the issue may look like the following:
name: CI
on: [push]
jobs:
build-test:
runs-on: ubuntu-latest
steps:
- name: Running PHPUnit Tests
run: script.sh
#How to Fix the Issue?
You can fix this issue by:
- Adding execution permissions to the file, and;
- Pushing the changes to the remote repository.
For example, on Linux or macOS, you can run the following command to set execution permission on the file:
$ chmod +x script.sh
On Windows, you can do the same using the following command:
$ git update-index --chmod=+x script.sh
Once you've done that, you should push your changes to the remote repository, for example, like so:
$ git add script.sh
$ git commit -m '...'
$ git push
Once you have completed these steps, you can retry running your GitHub action, and the "Permission denied" error should no longer occur.